onnx_ir.traversal¶

Utilities for traversing the IR graph.

class onnx_ir.traversal.RecursiveGraphIterator(graph_like, *, recursive=None, reverse=False)[source]¶
Parameters:
  • graph_like (GraphLike)

  • recursive (Callable[[_core.Node], bool] | None)

  • reverse (bool)

__abstractmethods__ = frozenset({})¶
__annotations__ = {}¶
__dict__ = mappingproxy({'__module__': 'onnx_ir.traversal', '__init__': <function RecursiveGraphIterator.__init__>, '__iter__': <function RecursiveGraphIterator.__iter__>, '__next__': <function RecursiveGraphIterator.__next__>, '_recursive_node_iter': <function RecursiveGraphIterator._recursive_node_iter>, '_iterate_subgraphs': <function RecursiveGraphIterator._iterate_subgraphs>, '__reversed__': <function RecursiveGraphIterator.__reversed__>, '__orig_bases__': (collections.abc.Iterator[onnx_ir.Node], collections.abc.Reversible[onnx_ir.Node]), '__dict__': <attribute '__dict__' of 'RecursiveGraphIterator' objects>, '__weakref__': <attribute '__weakref__' of 'RecursiveGraphIterator' objects>, '__doc__': None, '__abstractmethods__': frozenset(), '_abc_impl': <_abc._abc_data object>, '__annotations__': {}})¶
__init__(graph_like, *, recursive=None, reverse=False)[source]¶

Iterate over the nodes in the graph, recursively visiting subgraphs.

Parameters:
  • graph_like (Graph | Function | GraphView) – The graph to traverse.

  • recursive (Callable[[Node], bool] | None) – A callback that determines whether to recursively visit the subgraphs contained in a node. If not provided, all nodes in subgraphs are visited.

  • reverse (bool) – Whether to iterate in reverse order.

__iter__()[source]¶
Return type:

Self

__module__ = 'onnx_ir.traversal'¶
__next__()[source]¶

Return the next item from the iterator. When exhausted, raise StopIteration

Return type:

Node

__orig_bases__ = (collections.abc.Iterator[onnx_ir.Node], collections.abc.Reversible[onnx_ir.Node])¶
__reversed__()[source]¶
Return type:

Iterator[Node]

__weakref__¶

list of weak references to the object (if defined)