-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify the implementation of Taichi ops in Python #7447
Labels
refactor
Refactor of API or codebases
Comments
strongoier
added a commit
that referenced
this issue
Mar 1, 2023
This was referenced Mar 6, 2023
strongoier
added a commit
that referenced
this issue
Mar 13, 2023
ailzhang
pushed a commit
that referenced
this issue
Mar 17, 2023
… numpy arrays (#7559) Issue: #7447 ### Brief Summary This PR corresponds to step 3 of #7447. The code paths in `matrix.py` and `ops.py` have been significantly simplified: - The `Matrix` class, which is for Python scope, now only contains two cases, numpy arrays for values and nested lists for host access of `SNode`/`Ndarray`. Redundant internal functions have been removed. `dt` now has effects because numpy arrays have types. - No more `element_wise_xxx`, `uniform_matrix_inputs` and `@unary, @binary` decorators. The full dispatching logic for ops is in unique entrances `_unary_operation/_binary_operation`. Note that Python-scope matrix slicing is temporarily disabled in this PR because the feature itself is incomplete - only read is supported. It can be re-supported in a better way in the future. Taichi-scope matrix slicing still works properly. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels
pushed a commit
to quadpixels/taichi
that referenced
this issue
May 13, 2023
…i-dev#7456) Issue: taichi-dev#7447 ### Brief Summary This PR corresponds to step 1 of taichi-dev#7447. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels
pushed a commit
to quadpixels/taichi
that referenced
this issue
May 13, 2023
…ev#7474) Issue: taichi-dev#7447 ### Brief Summary This PR corresponds to step 2 of taichi-dev#7447. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels
pushed a commit
to quadpixels/taichi
that referenced
this issue
May 13, 2023
… numpy arrays (taichi-dev#7559) Issue: taichi-dev#7447 ### Brief Summary This PR corresponds to step 3 of taichi-dev#7447. The code paths in `matrix.py` and `ops.py` have been significantly simplified: - The `Matrix` class, which is for Python scope, now only contains two cases, numpy arrays for values and nested lists for host access of `SNode`/`Ndarray`. Redundant internal functions have been removed. `dt` now has effects because numpy arrays have types. - No more `element_wise_xxx`, `uniform_matrix_inputs` and `@unary, @binary` decorators. The full dispatching logic for ops is in unique entrances `_unary_operation/_binary_operation`. Note that Python-scope matrix slicing is temporarily disabled in this PR because the feature itself is incomplete - only read is supported. It can be re-supported in a better way in the future. Taichi-scope matrix slicing still works properly. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, Taichi ops in Python are implemented in a complicated way.
Matrix
,Struct
,Expr
classes inherit fromTaichiOperations
to make sure they support the same set of ops. The actual implementation of the ops are in https://github.com/taichi-dev/taichi/blob/master/python/taichi/lang/ops.py, which contains complicated dispatching according to whether a value is a Taichi expr or a Python value, a scalar or a compound type value, ... However, much of the logic is unnecessary because only a small set of code paths are actually valid. It will be much cleaner to only keep those valid paths. Therefore, I propose to simplify the logic in the following steps:fill
ofStruct
in v1.5.0, and remove them in v1.6.0. Such support is simply uncommon and unnecessary.Struct
inherit fromTaichiOperations
by implementing necessary ops likeassign
.Matrix
with numpy arrays and remove redundant code paths inops.py
.The text was updated successfully, but these errors were encountered: