Expand description
Derive macros for nuvec, re-exported as nuvec::Tree, nuvec::Static and
nuvec_nn::Module: use them through those crates.
One expansion engine generates Leaves and Tree impls; derive(Module) is
derive(Tree) plus a lint against bare Array fields. The generated code names only
::nuvec::__derive (or the module given by #[tree(crate = "..")] on the type).
Field attributes (#[tree(..)]; #[module(..)] is an alias under derive(Module)):
| attribute | meaning |
|---|---|
| (none) | a child tree (its leaves are visited) |
skip | not a leaf; hashed into the structure (the type must be Static); on an Array field (last path segment Array): a computed constant, neither hashed nor saved |
skip, static_unchecked | not a leaf, not hashed: baked into compiled traces |
buffer | an Array leaf that is saved and loaded but never trained |
mode | a bool mode flag (true = training), part of the structure |
rename = ".." | the path segment (fields and enum variants) |
Stability: no promise when this crate is depended on directly; depend on nuvec,
whose re-exports are semver-tracked.
Derive Macros§
- Module
- Derives
Treefor a model (it emits noimpl Module:Moduleis implemented for every tree), with one more check: a field typedArray(directly or inOption,VecorBox) withoutbufferorskipis an error suggestingParam. The check is syntactic: a type alias ofArrayis not caught. - Static
- Derives
Static(the type of a hashed#[tree(skip)]field) by hashing every field in order (enums: the variant index, then its fields). - Tree
- Derives
LeavesandTreefor a struct (named, tuple or unit) or an enum: the type’s array leaves get paths from its field names, as MLX’stree_flatten.