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

Unnecessary "Possible loss of precision" warning #8559

Open
agravier opened this issue Jul 10, 2024 · 2 comments
Open

Unnecessary "Possible loss of precision" warning #8559

agravier opened this issue Jul 10, 2024 · 2 comments

Comments

@agravier
Copy link

agravier commented Jul 10, 2024

Describe the bug
When assigning a constant to a field cell, Taichi emits a warning about possible loss of precision even though it's possible to determine at compile time that this is not the case

To Reproduce

import taichi as ti

ti.init(arch=ti.gpu)
init = ti.field(ti.i8, shape=(2, 3))
init[0, 0] = 1

Log/Screenshots

$ python tests/assign_precision.py
[Taichi] version 1.7.1, llvm 15.0.7, commit 0f143b2f, osx, python 3.10.9
[Taichi] Starting on arch=arm64
[W 07/10/24 11:33:51.553 33474852]
Assign may lose precision: unknown <- i8

Additional comments
Maybe I can just disable this check and runtime warning? It has a performance impact as it's emitted each time I do such an assignment.

@niuiniuin
Copy link

I met the exactly same situation. My wild guess is that the type of field cells probably is not recognized in the python scope. Doing the assignment in a taichi kernel can circumvent the warning.

import taichi as ti
ti.init(arch=ti.gpu, offline_cache=False)


init = ti.field(ti.i8, shape=(2, 3))

# init[0, 0] = 1
# print(init)

@ti.kernel
def assign_a_cell():
    init[0, 0] = ti.cast(1, ti.i8)
assign_a_cell()
print(init)

@niuiniuin
Copy link

Maybe this issue can be closed. They have fixed this bug in version 1.7.2 (#8553).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Untriaged
Development

No branches or pull requests

2 participants