Skip to content
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 vector and matrix dtypes in ti.field #7761

Merged
merged 1 commit into from
Apr 10, 2023

Conversation

ailzhang
Copy link
Contributor

@ailzhang ailzhang commented Apr 7, 2023

Issue: #6572

For backward compatibility reason we cannot change any positional arg and kwargs in ti.field but we this PR simply added support for vector and matrix dtypes.

Whether to deprecate ti.Vector.field and ti.Matrix.field can be a separate decision.

Testing: to avoid massive duplicated tests I just replaced all ti.Vector.field/ti.Matrix.field in test_fields.py to use this unified API. There're plenty of other files that use the old APIs so this should be fine for now.

Brief Summary

🤖 Generated by Copilot at 326d67e

Unified the creation of vector and matrix fields with a single field function in taichi.lang.impl. Updated the tests in test_field.py to use the new function and removed the deprecated ones. This improves the consistency and readability of the field API.

Walkthrough

🤖 Generated by Copilot at 326d67e

  • Rename and redefine field function to handle vector and matrix types (link,link,link)
  • Update field function docstring and examples in python/taichi/lang/impl.py (link)
  • Replace Vector.field and Matrix.field with field function in tests/python/test_field.py (link,link,link,link,link,link,link,link,link,link,link)

@netlify
Copy link

netlify bot commented Apr 7, 2023

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit 326d67e
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/642fe9d5c3fea500089b7d39
😎 Deploy Preview https://deploy-preview-7761--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@ailzhang ailzhang marked this pull request as ready for review April 7, 2023 11:29
@ailzhang ailzhang requested a review from bobcao3 April 7, 2023 11:29
Copy link
Collaborator

@bobcao3 bobcao3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I suspect all of this will be internalized into type system, once we get that done

@ailzhang ailzhang merged commit a533779 into taichi-dev:master Apr 10, 2023
ailzhang added a commit to ailzhang/taichi that referenced this pull request Apr 12, 2023
Issue: taichi-dev#6572 

For backward compatibility reason we cannot change any positional arg
and kwargs in `ti.field` but we this PR simply added support for vector
and matrix dtypes.

Whether to deprecate `ti.Vector.field` and `ti.Matrix.field` can be a
separate decision.

Testing: to avoid massive duplicated tests I just replaced all
`ti.Vector.field/ti.Matrix.field` in `test_fields.py` to use this
unified API. There're plenty of other files that use the old APIs so
this should be fine for now.

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

Unified the creation of vector and matrix fields with a single `field`
function in `taichi.lang.impl`. Updated the tests in `test_field.py` to
use the new function and removed the deprecated ones. This improves the
consistency and readability of the field API.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

* Rename and redefine `field` function to handle vector and matrix types
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L19-R19),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L698-R704),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Update `field` function docstring and examples in
`python/taichi/lang/impl.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Replace `Vector.field` and `Matrix.field` with `field` function in
`tests/python/test_field.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L38-R39),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L55-R57),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L135-R137),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L141-R144),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L171-R174),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L177-R181),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L197-R203),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L207-R212),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L215-R221),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L295-R300),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L302-R308))
quadpixels pushed a commit to quadpixels/taichi that referenced this pull request May 13, 2023
Issue: taichi-dev#6572 

For backward compatibility reason we cannot change any positional arg
and kwargs in `ti.field` but we this PR simply added support for vector
and matrix dtypes.

Whether to deprecate `ti.Vector.field` and `ti.Matrix.field` can be a
separate decision.

Testing: to avoid massive duplicated tests I just replaced all
`ti.Vector.field/ti.Matrix.field` in `test_fields.py` to use this
unified API. There're plenty of other files that use the old APIs so
this should be fine for now.

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

Unified the creation of vector and matrix fields with a single `field`
function in `taichi.lang.impl`. Updated the tests in `test_field.py` to
use the new function and removed the deprecated ones. This improves the
consistency and readability of the field API.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at 326d67e</samp>

* Rename and redefine `field` function to handle vector and matrix types
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L19-R19),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577L698-R704),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Update `field` function docstring and examples in
`python/taichi/lang/impl.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-99744c5ae5f6a754d6f68408fdc64fb0d6097216518a7f3d1ef43ffe12599577R760-R805))
* Replace `Vector.field` and `Matrix.field` with `field` function in
`tests/python/test_field.py`
([link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L38-R39),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L55-R57),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L135-R137),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L141-R144),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L171-R174),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L177-R181),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L197-R203),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L207-R212),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L215-R221),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L295-R300),[link](https://github.com/taichi-dev/taichi/pull/7761/files?diff=unified&w=0#diff-c08dd53cc282976d42e5643ea69e8e30e390e2ebd2f4e73f2789f84ac56f2494L302-R308))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants