-
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
[Lang] Support ndarray argument for real function #8188
Merged
taichi-gardener
merged 8 commits into
gh/lin-hitonami/8/base
from
gh/lin-hitonami/8/head
Jun 19, 2023
Merged
[Lang] Support ndarray argument for real function #8188
taichi-gardener
merged 8 commits into
gh/lin-hitonami/8/base
from
gh/lin-hitonami/8/head
Jun 19, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ghstack-poisoned]
lin-hitonami
added a commit
that referenced
this pull request
Jun 15, 2023
ghstack-source-id: 37c69d56ddbb41a09d00bb6361eadd17b2fdb118 Pull Request resolved: #8188
[ghstack-poisoned]
lin-hitonami
added a commit
that referenced
this pull request
Jun 15, 2023
ghstack-source-id: 78a359fac9fc628ed0bc578dec9d968b67dcb97b Pull Request resolved: #8188
[ghstack-poisoned]
lin-hitonami
added a commit
that referenced
this pull request
Jun 15, 2023
ghstack-source-id: d4d28d83721112b58796a18d648eb32447485e7a Pull Request resolved: #8188
[ghstack-poisoned]
This was referenced Jun 15, 2023
lin-hitonami
added a commit
that referenced
this pull request
Jun 15, 2023
ghstack-source-id: d4d28d83721112b58796a18d648eb32447485e7a Pull Request resolved: #8188
[ghstack-poisoned]
lin-hitonami
added a commit
that referenced
this pull request
Jun 15, 2023
ghstack-source-id: 346f82cd7e292567311a53974bfa1f66a3b23384 Pull Request resolved: #8188
[ghstack-poisoned]
lin-hitonami
added a commit
that referenced
this pull request
Jun 15, 2023
ghstack-source-id: 346f82cd7e292567311a53974bfa1f66a3b23384 Pull Request resolved: #8188
<!-- copilot:all --> ### <samp>🤖 Generated by Copilot at a936066</samp> ### Summary 🧮🧪🎁 <!-- 1. 🧮 for adding the binding for the `insert_ndarray_param` method. 2. 🧪 for modifying and adding the tests for the functionality. 3. 🎁 for enabling the feature of passing `ti.ndarray` as arguments. --> This pull request adds support for passing `ti.ndarray` as arguments to `ti.func` and `ti.experimental.real_func`, which allows users to write more flexible and generic functions that can operate on different types of arrays. It also updates and adds some tests to verify the correctness and error handling of this feature. > _`AnyArray` is the key to unleash the power_ > _Pass it to the `func` and `real_func` in the hour_ > _Invoke the `insert_ndarray_param` to bind the data_ > _Break the limits of the backends and the taichi_ ### Walkthrough * Import `AnyArray` class to support unified indexing and arithmetic operations for `ti.Matrix` and `ti.ndarray` ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1R15)) * Modify `Func.__call__` to return `arg_features` of arguments, which are tuples of element type, dimension, needs_grad, and boundary attributes ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1L229-R235)) * Add branch to `Func.func_call_rvalue` to handle `AnyArray` arguments with `ndarray_type.NdarrayType` annotations, and append pointer to `AnyArray` data to `non_template_args` ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1R261-R266)) * Modify `Func.do_compile` to take `arg_features` as input and pass them to `_get_tree_and_ctx`, which generates AST and context for function ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1L277-R287)) * Add branch to `TaichiCallableTemplateMapper.extract_arg` to return `arg_features` for `AnyArray` arguments ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1R415-R418)) * Add binding for `Function.insert_ndarray_param` to Python interface, which inserts pointer to `AnyArray` data to function parameters and sets flag ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-af631a0c71978fe591e17005f01f7c06bc30ae36c65df306bbb3b08ade770167R720)) * Modify and add tests for passing `ti.ndarray` to `ti.func` and `ti.experimental.real_func` in `test_ndarray.py` ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0L1008-R1051)) [ghstack-poisoned]
lin-hitonami
added a commit
that referenced
this pull request
Jun 16, 2023
ghstack-source-id: 84a312b25b980873395cbbc847144897c9c2e797 Pull Request resolved: #8188
<!-- copilot:all --> ### <samp>🤖 Generated by Copilot at a936066</samp> ### Summary 🧮🧪🎁 <!-- 1. 🧮 for adding the binding for the `insert_ndarray_param` method. 2. 🧪 for modifying and adding the tests for the functionality. 3. 🎁 for enabling the feature of passing `ti.ndarray` as arguments. --> This pull request adds support for passing `ti.ndarray` as arguments to `ti.func` and `ti.experimental.real_func`, which allows users to write more flexible and generic functions that can operate on different types of arrays. It also updates and adds some tests to verify the correctness and error handling of this feature. > _`AnyArray` is the key to unleash the power_ > _Pass it to the `func` and `real_func` in the hour_ > _Invoke the `insert_ndarray_param` to bind the data_ > _Break the limits of the backends and the taichi_ ### Walkthrough * Import `AnyArray` class to support unified indexing and arithmetic operations for `ti.Matrix` and `ti.ndarray` ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1R15)) * Modify `Func.__call__` to return `arg_features` of arguments, which are tuples of element type, dimension, needs_grad, and boundary attributes ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1L229-R235)) * Add branch to `Func.func_call_rvalue` to handle `AnyArray` arguments with `ndarray_type.NdarrayType` annotations, and append pointer to `AnyArray` data to `non_template_args` ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1R261-R266)) * Modify `Func.do_compile` to take `arg_features` as input and pass them to `_get_tree_and_ctx`, which generates AST and context for function ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1L277-R287)) * Add branch to `TaichiCallableTemplateMapper.extract_arg` to return `arg_features` for `AnyArray` arguments ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-a157043b38542c8145447ff342fda65fe4d54fb777fe514daa70007e83e20dc1R415-R418)) * Add binding for `Function.insert_ndarray_param` to Python interface, which inserts pointer to `AnyArray` data to function parameters and sets flag ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-af631a0c71978fe591e17005f01f7c06bc30ae36c65df306bbb3b08ade770167R720)) * Modify and add tests for passing `ti.ndarray` to `ti.func` and `ti.experimental.real_func` in `test_ndarray.py` ([link](https://github.com/taichi-dev/taichi/pull/8188/files?diff=unified&w=0#diff-ca3c8d1edb25b6a7f4affbb79b2e3e74f73b3757e5d465258ce42ea9eb09fbc0L1008-R1051)) [ghstack-poisoned]
lin-hitonami
added a commit
that referenced
this pull request
Jun 16, 2023
ghstack-source-id: e8d7bbed74d451affa1ab3db3864e0dc51417edd Pull Request resolved: #8188
jim19930609
approved these changes
Jun 19, 2023
/land |
taichi-gardener
pushed a commit
that referenced
this pull request
Jun 19, 2023
ghstack-source-id: e8d7bbed74d451affa1ab3db3864e0dc51417edd Pull Request resolved: #8188
L2ncE
pushed a commit
to L2ncE/taichi
that referenced
this pull request
Jun 20, 2023
ghstack-source-id: e8d7bbed74d451affa1ab3db3864e0dc51417edd Pull Request resolved: taichi-dev#8188
PGZXB
pushed a commit
to PGZXB/taichi
that referenced
this pull request
Jul 13, 2023
ghstack-source-id: e8d7bbed74d451affa1ab3db3864e0dc51417edd Pull Request resolved: taichi-dev#8188
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤖 Generated by Copilot at a936066
Summary
🧮🧪🎁
This pull request adds support for passing
ti.ndarray
as arguments toti.func
andti.experimental.real_func
, which allows users to write more flexible and generic functions that can operate on different types of arrays. It also updates and adds some tests to verify the correctness and error handling of this feature.Walkthrough
AnyArray
class to support unified indexing and arithmetic operations forti.Matrix
andti.ndarray
(link)Func.__call__
to returnarg_features
of arguments, which are tuples of element type, dimension, needs_grad, and boundary attributes (link)Func.func_call_rvalue
to handleAnyArray
arguments withndarray_type.NdarrayType
annotations, and append pointer toAnyArray
data tonon_template_args
(link)Func.do_compile
to takearg_features
as input and pass them to_get_tree_and_ctx
, which generates AST and context for function (link)TaichiCallableTemplateMapper.extract_arg
to returnarg_features
forAnyArray
arguments (link)Function.insert_ndarray_param
to Python interface, which inserts pointer toAnyArray
data to function parameters and sets flag (link)ti.ndarray
toti.func
andti.experimental.real_func
intest_ndarray.py
(link)Stack from ghstack (oldest at bottom):