Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lang] Support the functions of dataclass as kernel argument and retu…
…rn value (#7865) Issue: fixes #7822 <!-- copilot:all --> ### <samp>🤖 Generated by Copilot at 4ae87d7</samp> ### Summary 🧪🛠️🚀 <!-- 1. 🧪 - This emoji represents testing, experimentation, or science, and can be used to indicate the addition of test cases or the verification of functionality. 2. 🛠️ - This emoji represents tools, construction, or repair, and can be used to indicate the addition of a new feature or the improvement of an existing one. 3. 🚀 - This emoji represents speed, launch, or innovation, and can be used to indicate the enhancement of performance, the expansion of capabilities, or the introduction of a novel idea. --> This pull request enables data classes defined by `ti.dataclass` to have methods decorated by `ti.func` and `ti.kernel`. It also adds tests to check the functionality and correctness of this feature. > _`StructType` creates the data class of doom_ > _With `__struct_methods` to unleash its power_ > _Call them from Python, or pass them to `ti.kernel`_ > _`ti.func` returns them, the ultimate metal_ ### Walkthrough * Add `__struct_methods` attribute to data class dictionaries to enable access of methods defined in `ti.dataclass` decorator ([link](https://github.com/taichi-dev/taichi/pull/7865/files?diff=unified&w=0#diff-3154e0533b9fd63e663c16c2e87c65068c3b002a65cf80529b6577d173bdb5feR633), [link](https://github.com/taichi-dev/taichi/pull/7865/files?diff=unified&w=0#diff-3154e0533b9fd63e663c16c2e87c65068c3b002a65cf80529b6577d173bdb5feR654)) * Add test cases for using `ti.func` and `ti.kernel` as methods of data classes, both as kernel arguments and kernel returns, in `test_struct.py` ([link](https://github.com/taichi-dev/taichi/pull/7865/files?diff=unified&w=0#diff-e87bf5cb1cd09e10b5cfa001ab2ef18f31a242db3a7b66ee98a76d60b1615e71R79-R130))
- Loading branch information