Skip to main content

Crate nuvec_macros

Crate nuvec_macros 

Source
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)):

attributemeaning
(none)a child tree (its leaves are visited)
skipnot 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_uncheckednot a leaf, not hashed: baked into compiled traces
bufferan Array leaf that is saved and loaded but never trained
modea 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 Tree for a model (it emits no impl Module: Module is implemented for every tree), with one more check: a field typed Array (directly or in Option, Vec or Box) without buffer or skip is an error suggesting Param. The check is syntactic: a type alias of Array is 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 Leaves and Tree for a struct (named, tuple or unit) or an enum: the type’s array leaves get paths from its field names, as MLX’s tree_flatten.