tree-math icon indicating copy to clipboard operation
tree-math copied to clipboard

Transform for defining dataclasses with VectorMixin like flax.struct

Open shoyer opened this issue 2 years ago • 1 comments

It would be nice to have an easy way to define dataclasses that are also tree-math vectors.

We could borrow the syntax of flax.struct here: https://flax.readthedocs.io/en/latest/flax.struct.html

Example usage:

from tree_math import struct

@struct
class FluidState:
  velocity_x: Array
  velocity_y: Array
  pressure: Array

shoyer avatar Feb 15 '22 21:02 shoyer

CC @jamieas who started on work on this

shoyer avatar Feb 15 '22 23:02 shoyer

This completed. See "Custom vector classes" in the README for usage instructions.

shoyer avatar May 18 '23 17:05 shoyer