-
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] Fix the element_type of the AnyArray #8192
Merged
taichi-gardener
merged 5 commits into
gh/lin-hitonami/11/base
from
gh/lin-hitonami/11/head
Jun 19, 2023
Merged
[lang] Fix the element_type of the AnyArray #8192
taichi-gardener
merged 5 commits into
gh/lin-hitonami/11/base
from
gh/lin-hitonami/11/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]
This was referenced Jun 15, 2023
[ghstack-poisoned]
[ghstack-poisoned]
ailzhang
reviewed
Jun 16, 2023
<!-- copilot:all --> ### <samp>🤖 Generated by Copilot at 0176872</samp> ### Summary 📝🔬🆕 <!-- 1. 📝 - This emoji can represent the change of modifying the `decl_ndarray_arg` function to pass the `element_type` to the `AnyArray` constructor, since this is a code change that involves writing or editing some code. 2. 🔬 - This emoji can represent the change of adding `element_type` argument to `AnyArray` constructor and using it in `get_type` and `grad` methods, since this is a code change that involves improving the type handling and gradient computation of arbitrary arrays, which are related to scientific or mathematical operations. 3. 🆕 - This emoji can represent the change of introducing a new argument to the `AnyArray` constructor, since this is a code change that involves adding a new feature or functionality to the existing code. --> Improved type handling and gradient computation of `AnyArray` arguments in Taichi kernels and functions. Added `element_type` parameter to `AnyArray` constructor and `decl_ndarray_arg` function. > _To declare an array argument_ > _We pass the element type along_ > _This helps `AnyArray`_ > _To know what to say_ > _When it calls `get_type` or `grad`_ ### Walkthrough * Add `element_type` argument to `AnyArray` constructor and store it as an attribute ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L18-R20), [link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-575efc738df7b1202370c2531ec82232dc7f287b2bec4999af03ef40da4f5deeL111-R111)) * Return stored `element_type` in `AnyArray.get_type` method instead of inferring from pointer ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L36-R37)) * Pass stored `element_type` to `AnyArray` constructor in `AnyArray.grad` method to preserve type information in gradient array ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L43-R44)) [ghstack-poisoned]
<!-- copilot:all --> ### <samp>🤖 Generated by Copilot at 0176872</samp> ### Summary 📝🔬🆕 <!-- 1. 📝 - This emoji can represent the change of modifying the `decl_ndarray_arg` function to pass the `element_type` to the `AnyArray` constructor, since this is a code change that involves writing or editing some code. 2. 🔬 - This emoji can represent the change of adding `element_type` argument to `AnyArray` constructor and using it in `get_type` and `grad` methods, since this is a code change that involves improving the type handling and gradient computation of arbitrary arrays, which are related to scientific or mathematical operations. 3. 🆕 - This emoji can represent the change of introducing a new argument to the `AnyArray` constructor, since this is a code change that involves adding a new feature or functionality to the existing code. --> Improved type handling and gradient computation of `AnyArray` arguments in Taichi kernels and functions. Added `element_type` parameter to `AnyArray` constructor and `decl_ndarray_arg` function. > _To declare an array argument_ > _We pass the element type along_ > _This helps `AnyArray`_ > _To know what to say_ > _When it calls `get_type` or `grad`_ ### Walkthrough * Add `element_type` argument to `AnyArray` constructor and store it as an attribute ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L18-R20), [link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-575efc738df7b1202370c2531ec82232dc7f287b2bec4999af03ef40da4f5deeL111-R111)) * Return stored `element_type` in `AnyArray.get_type` method instead of inferring from pointer ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L36-R37)) * Pass stored `element_type` to `AnyArray` constructor in `AnyArray.grad` method to preserve type information in gradient array ([link](https://github.com/taichi-dev/taichi/pull/8192/files?diff=unified&w=0#diff-2e623ee0b0eec1b200fead36c0627a3c54738f6d83d79757398dc67decc01da8L43-R44)) [ghstack-poisoned]
lin-hitonami
changed the title
[lang] Record the element_type of the AnyArray
[lang] Fix the element_type of the AnyArray
Jun 16, 2023
jim19930609
approved these changes
Jun 19, 2023
taichi-gardener
pushed a commit
that referenced
this pull request
Jun 19, 2023
ghstack-source-id: 938770dea60ac879c40fe25d4f67a50b44b03234 Pull Request resolved: #8192
L2ncE
pushed a commit
to L2ncE/taichi
that referenced
this pull request
Jun 20, 2023
ghstack-source-id: 938770dea60ac879c40fe25d4f67a50b44b03234 Pull Request resolved: taichi-dev#8192
PGZXB
pushed a commit
to PGZXB/taichi
that referenced
this pull request
Jul 13, 2023
ghstack-source-id: 938770dea60ac879c40fe25d4f67a50b44b03234 Pull Request resolved: taichi-dev#8192
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 d183bb1
Summary
🐛🧮🚀
Fix a bug in
AnyArray.get_type
that caused incorrect type inference for external arrays. Add a new functionget_external_tensor_element_type
to the Python export module to support the bug fix.Walkthrough
get_type
method of theAnyArray
class that caused incorrect type inference and compilation errors for external arrays (link)get_external_tensor_element_type
function to the Python export module to expose the C++ function that returns the element type of an external array (link)Stack from ghstack (oldest at bottom):