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

The filed in Taichi can only be accessed through the index of I32? #6159

Closed
sanxiadaba opened this issue Sep 25, 2022 · 1 comment · Fixed by #6276
Closed

The filed in Taichi can only be accessed through the index of I32? #6159

sanxiadaba opened this issue Sep 25, 2022 · 1 comment · Fixed by #6276
Assignees
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@sanxiadaba
Copy link

My system is Win10 and Taichi version is 1.1.3

The filed in Taichi can only be accessed through the index of I32. If default_ip=ti. I64 is set at the beginning, it will fail to access the index below
The following code will report an error

import taichi as ti

ti.init(arch=ti.cpu, default_ip=ti.i64)
n = 1024
val = ti.field(dtype=ti.i64, shape=n)
val.fill(1)


@ti.kernel
def prefix_sum():
    ti.loop_config(serialize=True)
    for i in range(1, 1024):
        val[i] += val[i - 1]


prefix_sum()
print(val)

[Taichi] version 1.1.3, llvm 10.0.0, commit 1262a70, win, python 3.10.7
[Taichi] Starting on arch=x64
C:\Users\001\AppData\Local\Programs\Python\Python310\lib\site-packages\taichi\lang\ast\ast_transformer.py:38: Warning: Casting range_for
boundary values from i64 to i32, which may cause numerical issues
warnings.warn(
[I 09/25/22 21:07:25.771 20228] [D:/a/taichi/taichi/taichi/codegen/llvm/llvm_codegen_utils.cpp:check_func_call_signature@134] Function :
Dense_lookup_element
[I 09/25/22 21:07:25.772 20228] [D:/a/taichi/taichi/taichi/codegen/llvm/llvm_codegen_utils.cpp:check_func_call_signature@135] Type :
i8* (i8*, i8*, i32)
[E 09/25/22 21:07:25.773 20228] [D:/a/taichi/taichi/taichi/codegen/llvm/llvm_codegen_utils.cpp:check_func_call_signature@144] parameter 2 mismatch: required=i32, provided=i64

Traceback (most recent call last):
File "c:\Code\github\my_python_function\Test\test22.py", line 16, in
prefix_sum()
File "C:\Users\001\AppData\Local\Programs\Python\Python310\lib\site-packages\taichi\lang\kernel_impl.py", line 915, in wrapped
return primal(*args, **kwargs)
File "C:\Users\001\AppData\Local\Programs\Python\Python310\lib\site-packages\taichi\lang\kernel_impl.py", line 842, in call
return self.runtime.compiled_functionskey
File "C:\Users\001\AppData\Local\Programs\Python\Python310\lib\site-packages\taichi\lang\kernel_impl.py", line 769, in func__
raise e from None
File "C:\Users\001\AppData\Local\Programs\Python\Python310\lib\site-packages\taichi\lang\kernel_impl.py", line 766, in func__
t_kernel(launch_ctx)
RuntimeError: [D:/a/taichi/taichi/taichi/codegen/llvm/llvm_codegen_utils.cpp:check_func_call_signature@144] parameter 2 mismatch: required=i32, provided=i64

No error will be reported after the transformation

import taichi as ti

ti.init(arch=ti.cpu, default_ip=ti.i64)
n = 1024
val = ti.field(dtype=ti.i64, shape=n)
val.fill(1)


@ti.kernel
def prefix_sum():
    ti.loop_config(serialize=True)
    for i in range(1, 1024):
        val[ti.i32(i)] += val[ti.i32(i - 1)]


prefix_sum()
print(val)
@sanxiadaba sanxiadaba added the potential bug Something that looks like a bug but not yet confirmed label Sep 25, 2022
@taichi-gardener taichi-gardener moved this to Untriaged in Taichi Lang Sep 25, 2022
@erizmr erizmr moved this from Untriaged to Todo in Taichi Lang Sep 30, 2022
Repository owner moved this from Todo to Done in Taichi Lang Oct 11, 2022
jim19930609 added a commit that referenced this issue Oct 11, 2022
@sanxiadaba
Copy link
Author

sanxiadaba commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug Something that looks like a bug but not yet confirmed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants