taichi-dev/taichi

Invoke materialize() only before calling a Taichi kernel

Open

#2,730 opened on Aug 19, 2021

View on GitHub
 (5 comments) (0 reactions) (2 assignees)C++ (28,195 stars) (2,384 forks)batch import
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:

https://github.com/taichi-dev/taichi/blob/9c108ff0e1ce51ba991f1bd4476892d3823fe13a/python/taichi/lang/impl.py#L294-L317

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

  1. We used to have to call materialize() before collecting SNode's information. shape has 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.
  1. There are places where an exception should be thrown if the program is not materialized yet (instead of doing an implicit materialization):

Additional comments Add any other context or screenshots about the feature request here.

Contributor guide