taichi-dev/taichi

[Lang] Python-scope matrix/vector operations

Open

#1008 aperta il 17 mag 2020

Vedi su GitHub
 (7 commenti) (1 reazione) (1 assegnatario)C++ (2384 fork)batch import
feature requestgood first issuewelcome contribution

Metriche repository

Star
 (28.195 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

Concisely describe the proposed feature Currently, the Matrix class operations (e.g. matrix add/multiply/scale) can happen only in Taichi kernels. In some cases having these work in Python-scope is necessary. For example, https://github.com/taichi-dev/taichi/pull/1006/files#diff-9ce279666131a93e7f2be366688b2fa1R52-R67

Without Python-scope matrix operation supports users have to fall back on numpy and the conversion between Taichi and numpy can be troublesome.

Describe the solution you'd like (if any) Dispatch matrix operations according to the scope. Keep the old behavior if the operation happens in Taichi-scope, but evaluate the results immediately in Python-scope.

To decide the scope, use ti.get_runtime().inside_kernel. E.g.,

https://github.com/taichi-dev/taichi/blob/6dce0c4bceafcbf8347684802ef29c9fb84266d7/python/taichi/lang/expr.py#L143

Guida contributor