-
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] Customized struct support #2627
Conversation
* [vulkan] Add Vulkan API * fix * support osx * [skip ci] enforce code format Co-authored-by: Taichi Gardener <[email protected]>
* [vulkan] Add per kernel info structs * trace
Ping :-) ? |
…into custom-struct
…into custom-struct
/format |
/format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work!!
/format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you also resolve conflicts with master?
/format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for your effort!
Related issue = close #2614
Adds customized struct support to Taichi fields, e.g.:
The implementation generally follows the Matrix and MatrixField class with similar API definitions, while members of a Struct can be only accessed using attribute names.
A CompoundType interface has been implemented to instantiate vector, matrices, and structs with pre-defined shapes or members. This allows for a custom struct to have vectors, matrices and nested structs as members.
Local structs in both python and Taichi scopes can be initialized with either keyword arguments and dictionaries:
In addition to directly invoking initializers of
Struct
andMatrix
classes,CompoundType
instances can be also called to create matrix or struct instances. Vectors and matrices can be created using GLSL-like broadcast syntax since the shape of the vector or matrix is already known: