Docs / nablatensor-tensor / com.nablatensor.tensor.tree
final class
TreeUtil
Utilities for traversing and rebuilding nested parameter trees.
Methods
Flattens all non-container values into leaves.
Flattens a tree with an additional leaf predicate. null remains an empty node even when the predicate accepts it.
Rebuilds a tree, requiring exactly leafCount() leaves.
Returns a tree's leaves in deterministic traversal order.
Returns a tree's immutable structural definition.
Applies a unary operation to every leaf and rebuilds the original structure.
Applies a binary operation to matching leaves in two trees.
Applies an operation to matching leaves in one or more trees.
Folds leaves from left to right, beginning with initial.
Swaps two nested tree levels, as in JAX's tree_transpose.
Registers a node type. Registration is exact-class based, matching JAX's node registration semantics.
Closes each distinct tensor leaf once. Identity, rather than equals, is intentional: a repeated tensor is one owned buffer.
Flattens a Tensor-leaf tree into one rank-1 Tensor. Until concat and slicing primitives exist, this operation intentionally transfers through host memory.