import taichi as ti
ti.init(ti.cpu)
a = ti.field(ti.int32, shape=(3))
b = ti.field(ti.int32, shape=(3))
a.fill(1)
b.fill(2)
@ti.kernel
def test():
for i in b:
print(a[i])
a[i] = b[i]
print(a[i])
test()
import taichi as ti
ti.init(ti.cpu)
a = ti.field(ti.int32, shape=(3))
b = ti.field(ti.int32, shape=(3))
a.fill(1)
b.fill(2)
@ti.func
def field_copy(src: ti.template(), dst: ti.template()):
for I in ti.grouped(src):
dst[I] = src[I]
@ti.kernel
def test():
# copy b to a
field_copy(b, a)
print(a[0])
test()