taichi-dev/taichi

[Lang] Python-scope matrix/vector operations

Open

#1.008 geöffnet am 17. Mai 2020

Auf GitHub ansehen
 (7 Kommentare) (1 Reaktion) (1 zugewiesene Person)C++ (2.384 Forks)batch import
feature requestgood first issuewelcome contribution

Repository-Metriken

Stars
 (28.195 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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

Contributor Guide