Node
- class onnx_graphsurgeon.Node(op: str, name: str | None = None, attrs: Dict[str, object] | None = None, inputs: List[Tensor] | None = None, outputs: List[Tensor] | None = None, domain: str | None = None)
- Bases: - object- A node represents an operation in a graph, and consumes zero or more Tensors, and produces zero or more Tensors. - Parameters:
- op (str) – The operation this node performs. 
- name (str) – The name of this node. 
- attrs (Dict[str, object]) – A dictionary that maps attribute names to their values. 
- inputs (List[Tensor]) – A list of zero or more input Tensors. 
- outputs (List[Tensor]) – A list of zero or more output Tensors. 
- domain (str) – The domain of this node, 
 
 - class AttributeRef(name: str, type: type)
- Bases: - object- An AttributeRef is an attribute value which references an attribute in the parent function. A node’s attribute can only be an AttributeRef if the node lives inside a Function. - Parameters:
- name (str) – The name of the referenced attribute in the parent Function. 
- type (type) – The attribute’s type. 
 
 
 - 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:
 
 - subgraphs(recursive=False)
- Convenience function to iterate over all subgraphs which are contained in this node. Node subgraphs are found in attributes of ONNX control flow nodes such as ‘If’ and ‘Loop’. - Parameters:
- recursive (bool) – Whether to recurse into the subgraph nodes when looking for subgraphs. Defaults to False. 
- Returns:
- A generator which iterates over this node’s subgraphs.