chex icon indicating copy to clipboard operation
chex copied to clipboard

Analog to `flax.struct.dataclass`

Open homerjed opened this issue 1 year ago • 2 comments

Hi chex team,

Is there any potential for something like flax.struct.dataclass in chex?

Basically a kind of dataclass that can mark static arguments.

Two other variations include jax_dataclasses and simple-pytree though a chex official one would be cool for all its benefits of being part of chex.

Thank you!

homerjed avatar Mar 03 '23 10:03 homerjed

Check out equinox.Module. This does dataclass + pytree registration as with the other cases, and supports static fields (eqx.static_field).

It also correctly handles a number of other edge cases: subclassing, docstring handling, bound methods are also pytrees, etc.

patrick-kidger avatar Mar 15 '23 19:03 patrick-kidger

Thanks @patrick-kidger, I will definitely use equinox next time around, its design is incredible.

homerjed avatar Mar 19 '23 13:03 homerjed