-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Labels
questionQuestion on using TaichiQuestion on using Taichi
Description
Here is the problematic code:
import numpy as np
import taichi as ti
import copy
ti.init(arch=ti.cpu,default_ip=ti.i32, default_fp=ti.f32)
@ti.data_oriented
class Test:
def __init__(self, ini):
self.ini = ti.ndarray(shape=(10,), dtype=ti.i32)
self.ini.from_numpy(ini)
@ti.kernel
def run(self):
ini = self.ini
print(ini)
if __name__ == '__main__':
ini = np.arange(10)
test = Test(ini)
test.run()
print(test.ini.to_numpy())In it, I am simply trying to create a copy of self.ini in side a kernel function.
I get the following stack trace:
Invalid constant scalar data type: <class 'taichi.lang._ndarray.ScalarNdarray'>If instead I try to attribute to the ndarray within the kernel function,
self.ini[5] = 100I get the following error:
AssertionError: __getitem__ cannot be called in Taichi-scopeWhat am I doing wrong?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionQuestion on using TaichiQuestion on using Taichi
Type
Projects
Status
Untriaged