Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calling x.fill(1) for a field x of type ti.u8 raises warning #7678

Closed
neozhaoliang opened this issue Mar 29, 2023 · 0 comments
Closed

calling x.fill(1) for a field x of type ti.u8 raises warning #7678

neozhaoliang opened this issue Mar 29, 2023 · 0 comments
Assignees
Milestone

Comments

@neozhaoliang
Copy link
Contributor

To reproduce:

x = ti.field(ti.u8, 100)
x.fill(1)

raise the warning message

[W 03/29/23 10:53:27.516 328640] [type_check.cpp:type_check_store@36] [$25] Global store may lose precision: u8 <- i32
File "/home/zhao/taichi/python/taichi/_kernels.py", line 24, in fill_tensor:
        tensor[I] = val
        ^^^^^^^^^^^^^^^

However, when one tries to use ti.u8(1) to cast the constant to ti.u8 type, it raises error

TypeError: 'taichi._lib.core.taichi_python.DataType' object is not callable
@github-project-automation github-project-automation bot moved this to Untriaged in Taichi Lang Mar 29, 2023
@jim19930609 jim19930609 self-assigned this Mar 31, 2023
@jim19930609 jim19930609 moved this from Untriaged to Todo in Taichi Lang Mar 31, 2023
@jim19930609 jim19930609 added this to the v1.6.0 milestone Mar 31, 2023
neozhaoliang pushed a commit that referenced this issue Apr 27, 2023
Issue: ##7678

There's one potential hazard: if the user mistakenly filled a ti.field
with out-of-scope values (like filling a ti.field(ti.u8) with > 255),
it's just gonna overflow silently.
@github-project-automation github-project-automation bot moved this from Todo to Done in Taichi Lang Apr 28, 2023
quadpixels pushed a commit to quadpixels/taichi that referenced this issue May 13, 2023
Issue: #taichi-dev#7678

There's one potential hazard: if the user mistakenly filled a ti.field
with out-of-scope values (like filling a ti.field(ti.u8) with > 255),
it's just gonna overflow silently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants