Node
One node of a graph: its name, kind, operator code, attributes as plain Python values, the values it consumes and produces, and the edges that join it to other nodes. Holding a Node keeps the graph alive. After an edit the view finds its node again by name; once no node has that name, or a merge, a split or an extract consumes the graph, check() and every accessor raise InvalidArgumentError naming it, while ==, hash and repr keep working.
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, and finalize() packs the rest: load with weight_residency='borrowed' and read the weights before finalize().
check
checkcheck(self) -> None
check(self) -> None
check() -> None
None while the graph holds a node of this name; raises InvalidArgumentError naming it once it does not (an edit removed or renamed the node, or a merge, a split or an extract consumed the graph).
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.
in_degree
in_degreein_degree(self) -> int
in_degree(self) -> int
in_degree() -> int
len(in_edges()): parallel edges counted.
in_edges
in_edgesin_edges(self) -> list
in_edges(self) -> list
in_edges() -> list[Edge]
The edges entering this node in input-port order, one per port another node feeds (Mul(x, x) has two); a constant or state operand is an input but no edge.
input
inputinput(self, port: int) -> object
input(self, port: int) -> object
input(port) -> Value | None
The value on input port port, a constant or state operand included; None when nothing feeds the port (an omitted optional operand, a port the node lacks, any port of an Input node).
out_degree
out_degreeout_degree(self) -> int
out_degree(self) -> int
out_degree() -> int
len(out_edges()): parallel edges counted.
out_edges
out_edgesout_edges(self) -> list
out_edges(self) -> list
out_edges() -> list[Edge]
The edges leaving this node, one per read, in (output port, consumer name, consumer input port) order.
output
outputoutput(self, port: int) -> object
output(self, port: int) -> object
output(port) -> Value | None
The value on output port port; None when no operator and no graph output reads it, and for a port the node lacks.
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.