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

Left shift operation between int and taichi field element is not supported in taichi scope #1977

Closed
BillXu2000 opened this issue Oct 20, 2020 · 0 comments · Fixed by #1978
Closed
Labels
potential bug Something that looks like a bug but not yet confirmed

Comments

@BillXu2000
Copy link
Collaborator

Describe the bug

I want to use 1 << a[1] in taichi scope, where a is a taichi field, but a TypeError is raised.

To Reproduce

Run the code below.

import taichi as ti
ti.init(debug = True)
a = ti.field(dtype = ti.i32, shape = 3)

@ti.kernel
def fun():
    print(1 << a[1])

a[1] = 2
#print(1 << a[1]) #this line works properly
fun()

Log/Screenshots

bx2k@bx2k-MagicBook:/mnt/c/Users/BillXu2000/Desktop$ cmd.exe /c python3 test.py
[Taichi] mode=release
[Taichi] version 0.7.0, llvm 10.0.0, commit 0298bca3, win, python 3.8.6
[Taichi] Starting on arch=x64
[Taichi] materializing...
Traceback (most recent call last):
  File "test.py", line 11, in <module>
    fun()
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-pa
ckages\Python38\site-packages\taichi\lang\kernel.py", line 574, in wrapped
    return primal(*args, **kwargs)
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-pa
ckages\Python38\site-packages\taichi\lang\kernel.py", line 501, in __call__
    self.materialize(key=key, args=args, arg_features=arg_features)
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-pa
ckages\Python38\site-packages\taichi\lang\kernel.py", line 370, in materialize
    taichi_kernel = taichi_kernel.define(taichi_ast_generator)
  File "C:\Users\BillXu2000\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-pa
ckages\Python38\site-packages\taichi\lang\kernel.py", line 367, in taichi_ast_generator
    compiled()
  File "test.py", line 7, in fun
    print(1 << a[1])
TypeError: unsupported operand type(s) for <<: 'int' and 'Expr'
@BillXu2000 BillXu2000 added the potential bug Something that looks like a bug but not yet confirmed label Oct 20, 2020
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
None yet
Development

Successfully merging a pull request may close this issue.

1 participant