You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand that the plan is to remove ti.pyfunc in 1.6.0, but I found this to be a very important feature which I use all the time, so I'd like to make a case for keeping it in taichi.
In #4414, @lin-hitonami explained that even without ti.pyfunc, you can still create functions that work in both taichi scope and python scope using the following pattern:
because in ti.func(g), the f function that it calls is not transformed by ti.func, so this triggers an error:
File "c:\users\ldfra\code\taichi\taichi\python\taichi\lang\util.py", line 308, in wrapped
assert in_python_scope(), \
AssertionError: __getitem__ cannot be called in Taichi-scope
member functions of @ti.data_oriented classes:
Consider for example:
member functions struct types (@ti.dataclass). This is the same as with ti.data_oriented classes, because members of struct types are also callable from both taichi and python scope.
These are all very common use cases, and not having ti.pyfunc really makes writing large-scale taichi programs a lot more awkward. So please consider keeping ti.pyfunc. Alternatively, I would also greatly appreciate if you could help me identify other patterns that could solve all of the three aforementioned problems!
Hey @AmesingFlank thanks for bringing this up! We discussed this offline with @strongoier and @lin-hitonami and totally agreed this is a valid use case! We'll keep pyfunc and raise better error message when an invalid pyfunc is written/called instead. Cheers!
Hey @AmesingFlank thanks for bringing this up! We discussed this offline with @strongoier and @lin-hitonami and totally agreed this is a valid use case! We'll keep pyfunc and raise better error message when an invalid pyfunc is written/called instead. Cheers!
I understand that the plan is to remove
ti.pyfunc
in 1.6.0, but I found this to be a very important feature which I use all the time, so I'd like to make a case for keeping it in taichi.In #4414, @lin-hitonami explained that even without
ti.pyfunc
, you can still create functions that work in both taichi scope and python scope using the following pattern:While this does work for the simplest scenarios, there are many use cases that this pattern cannot support:
The solution proposed in #4414 does not work here:
because in
ti.func(g)
, thef
function that it calls is not transformed byti.func
, so this triggers an error:@ti.data_oriented
classes:Consider for example:
this would be very awkward without
ti.pyfunc
. The only solution I see is by doingwhich is quite bad in terms of readability
@ti.dataclass
). This is the same as withti.data_oriented
classes, because members of struct types are also callable from both taichi and python scope.These are all very common use cases, and not having
ti.pyfunc
really makes writing large-scale taichi programs a lot more awkward. So please consider keepingti.pyfunc
. Alternatively, I would also greatly appreciate if you could help me identify other patterns that could solve all of the three aforementioned problems!cc @lin-hitonami @strongoier @k-ye @ailzhang @yuanming-hu
The text was updated successfully, but these errors were encountered: