Skip to main content

Node

One node of a graph: its name, kind, operator code, attributes as plain Python values, and the values it consumes and produces. Valid while the graph is alive and unchanged; holding a Node keeps the graph alive.

attributes (property)​

The node's attributes as a dict of plain Python values: None, bool, int, float, str (an enum attribute is its enumerator's name), a list of ints or floats (an absent entry is None), a dtype, or a number.

inputs (property)​

The values the node consumes, in operand order.

kind (property)​

NodeKind.Op for an operator, NodeKind.Input for a graph input.

name (property)​

The node's name, unique in its graph.

op_code (property)​

The operator (an OpCode); OpCode.Custom for a custom operator.

outputs (property)​

The values the node produces, in output order.

__init__​

__init__(self, /, *args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

attribute​

attributeattribute(self, name: str) -> object

attribute(self, name: str) -> object

attribute(name) -> object

One attribute by name as a plain Python value; KeyError when the node has none by that name.

bound_tensors​

bound_tensorsbound_tensors(self) -> dict

bound_tensors(self) -> dict

bound_tensors() -> dict[str, Tensor]

The tensors a traced module bound into this operator, name to tensor in registration order, named by the operator's own slots (b for a projection's weight operand, bias): shared handles, no copy. {} for an Input node and for an operator that binds nothing; a compiled ONNX initializer is both a constant input and the operator's bound tensor, so an ONNX MatMul reports its b. A weight the module has already packed is not reported (read it from the module's named_parameters()); the pack releases the weight slot alone, so a packed projection still reports its bias. A default-residency layer packs on its first forward, which the trace runs: load with weight_residency='borrowed' and trace with bake=False to see the weights.

custom_name​

custom_namecustom_name(self) -> str

custom_name(self) -> str

custom_name() -> str

The operator's name when op_code is OpCode.Custom; '' otherwise.

fused_activation​

fused_activationfused_activation(self) -> object

fused_activation(self) -> object

fused_activation() -> str | None

The activation fused into the node ('relu', 'gelu', ...), or None when the node fuses none.

predecessors​

predecessorspredecessors(self) -> list

predecessors(self) -> list

predecessors() -> list[Node]

The nodes producing this node's inputs.

successors​

successorssuccessors(self) -> list

successors(self) -> list

successors() -> list[Node]

The nodes consuming this node's outputs.