taichi-dev/taichi

[Lang] Python-scope matrix/vector operations

Open

#1 008 ouverte le 17 mai 2020

Voir sur GitHub
 (7 commentaires) (1 réaction) (1 assigné)C++ (2 384 forks)batch import
feature requestgood first issuewelcome contribution

Métriques du dépôt

Stars
 (28 195 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

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

Guide contributeur