taichi-dev/taichi
View on GitHubInvoke materialize() only before calling a Taichi kernel
Open
#2,730 opened on Aug 19, 2021
good first issuerefactorwelcome contribution
Description
Concisely describe the proposed feature
Originally, materialize() was meant to be invoked immediately before the invocation of a @ti.kernel:
That is, this part is where materialize() is supposed to be called: https://github.com/taichi-dev/taichi/blob/711c299ca9abce4b8a632922ff89295c6939faf3/python/taichi/lang/kernel_impl.py#L383
It is now scattered in several places in the codebase, see
https://github.com/taichi-dev/taichi/search?l=Python&q=%22materialize%28%22
Describe the solution you'd like (if any)
The reasons are two-fold
- We used to have to call
materialize()before collecting SNode's information.shapehas been fixed by @strongoier 's work (#2600) now. However, there are still some places left. We will be happy to guide for the rest of the fix.
- https://github.com/taichi-dev/taichi/blob/0fa4c675a00fcb8eb2993dac427e7818aa7b04fe/python/taichi/lang/snode.py#L295-L305
- https://github.com/taichi-dev/taichi/blob/0fa4c675a00fcb8eb2993dac427e7818aa7b04fe/python/taichi/lang/field.py#L201-L205
- There are places where an exception should be thrown if the program is not materialized yet (instead of doing an implicit materialization):
- https://github.com/taichi-dev/taichi/blob/711c299ca9abce4b8a632922ff89295c6939faf3/python/taichi/lang/__init__.py
- https://github.com/taichi-dev/taichi/blob/efd66b57fd4438e3fad88450a55b2286e1e249c1/python/taichi/aot/module.py#L79
Additional comments Add any other context or screenshots about the feature request here.