taichi
taichi copied to clipboard
Struct-for parital
Concisely describe the proposed feature I would like to run struct-for partially (with some dims fixed) on a SNode field.
Describe the solution you'd like (if any) One possible solution is via slicing sparse data structure
@ti.kernel
def example():
#struct for a 3d sparse field on i=0
for j, k in data[0,:,:]:
do_some_work()
Another solution is via some function
@ti.kernel
def example():
#struct for a 3d sparse field on i=0
for j, k in ti.part_for(data, [0,:,:]):
do_some_work()
@xuhao1 I guess you can work around this by
for i, j, k in data:
if i == 0:
do_some_work()
right? Would you mind elaborate if there's any extra benefit you'd expect from this partial struct-for? Thanks a lot!
Hi @ailzhang Yes I am currently using
for i, j, k in data:
if i == 0:
do_some_work()
However, this implementation needs to visit all the memory of the SNode. This will bring overhead when data is quite large.
@xuhao1 Yea this is totally a reasonable feature request! Implementation wise might be a bit tricky tho. I feel like this is a good get started task for sparse. We'll put this in todo for now and let you know once we've implemented it. Thanks!