taichi-dev/taichi

[Lang] Python-scope matrix/vector operations

Open

#1,008 创建于 2020年5月17日

在 GitHub 查看
 (7 评论) (1 反应) (1 负责人)C++ (2,384 fork)batch import
feature requestgood first issuewelcome contribution

仓库指标

Star
 (28,195 star)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

贡献者指南