IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /get-started.md). For the complete documentation index, see llms.txt.
Skip to main content
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 class

TreeDef

TreeDef

class max.experimental.tree_utils.TreeDef(kind, children=(), keys=(), meta=None)

source

Bases: object

The shape of a tree, with its leaves abstracted away.

Equal structures rebuild each other’s leaves. Hashing skips the payloads.

Parameters:

child_keys

property child_keys: tuple[Any, ...]

source

keys, or positions if empty.

Type:

The key of each child

children

children: tuple[TreeDef, ...] = ()

source

The structure of each child, in leaf order.

keys

keys: tuple[Any, ...] = ()

source

One key per child, or empty when the children are positional.

kind

kind: str

source

"leaf" (a leaf slot), "static" (a value carried as-is in meta), "ref" (a repeat of an earlier value), or one of the container tags "list", "tuple", "namedtuple", "dict" and "node".

Type:

What this position holds

leaf_paths

property leaf_paths: tuple[str, ...]

source

The dotted path to each leaf, in leaf order.

meta

meta: Any = None

source

the value itself for "static", the referenced slot number for "ref", the concrete type for "namedtuple", and a (type, metadata) pair for "node".

Type:

Whatever the kind needs to rebuild

num_leaves

property num_leaves: int

source

The number of leaf slots in this structure; a "ref" counts none.