For the complete documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /get-started.md).
Python function
dataclass
dataclass()
max.tree.dataclass(cls: None = None, /, **kwargs: Any) → Callable[[type[_T]], type[_T]]
Makes a dataclass a tree node.
Usable bare or with dataclasses.dataclass() arguments.
from max import tree
@tree.dataclass
class AttentionInputs:
layer_idx: TensorValue
freqs_cis: TensorValue
indexer: TensorValue | None = None
@tree.dataclass(frozen=True)
class PLEInputs:
conv_pool: BufferValue
slot_idx: TensorValueThe generated __tree_flatten__ includes fields that are not None at
flatten time, in declaration order. The generated __tree_unflatten__
restores any absent field to None – a field is dropped only when it is
None, so a non-None default is not reapplied.
-
Parameters:
-
- cls – The class to decorate, or
Nonewhen called with arguments. - kwargs – Passed to
dataclasses.dataclass()whenclsis not already a dataclass.
- cls – The class to decorate, or
-
Returns:
-
The decorated class, or a decorator when called with arguments.