Node¶
-
class
onnx_graphsurgeon.
Node
(op: str, name: str = None, attrs: Dict[str, object] = None, inputs: List[Tensor] = None, outputs: List[Tensor] = None)¶ Bases:
object
A node represents an operation in a graph, and consumes zero or more Tensors, and produces zero or more Tensors.
- Parameters
-
i
(tensor_idx=0, producer_idx=0)¶ Convenience function to get a producer node of one of this node’s input tensors. Note that the parameters are swapped compared to the o() function; this is because tensors are likely to have only a single producer
For example:
assert node.i() == node.inputs[0].inputs[0] assert node.i(1, 2) == node.inputs[1].inputs[2]
- Parameters
tensor_idx (int) – The index of the input tensor of this node. Defaults to 0.
producer_idx (int) – The index of the producer of the input tensor, if the tensor has multiple producers. Defaults to 0
- Returns
The specified producer (input) node.
- Return type
-
o
(consumer_idx=0, tensor_idx=0)¶ Convenience function to get a consumer node of one of this node’s output tensors.
For example:
assert node.o() == node.outputs[0].outputs[0] assert node.o(2, 1) == node.outputs[1].outputs[2]
- Parameters
consumer_idx (int) – The index of the consumer of the input tensor. Defaults to 0.
tensor_idx (int) – The index of the output tensor of this node, if the node has multiple outputs. Defaults to 0.
- Returns
The specified consumer (output) node
- Return type
-
copy
(inputs: List[Tensor] = None, outputs: List[Tensor] = None, tensor_map=None)¶ Makes a shallow copy of this node, overriding input and output information.
Note: Generally, you should only ever make a copy of a Graph.