MCPcopy Create free account
hub / github.com/pytorch/executorch / bfs_trace_with_node_process

Function bfs_trace_with_node_process

exir/graph_module.py:136–153  ·  view source on GitHub ↗

Traverse the graph module and apply node_op to each node.

(
    gm: torch.fx.GraphModule, node_op: Callable[[torch.fx.Node], None]
)

Source from the content-addressed store, hash-verified

134
135
136def bfs_trace_with_node_process(
137 gm: torch.fx.GraphModule, node_op: Callable[[torch.fx.Node], None]
138) -> None:
139 """Traverse the graph module and apply node_op to each node."""
140
141 assert isinstance(gm, torch.fx.GraphModule), f"Expected GraphModule, got {type(gm)}"
142
143 queue = [gm]
144 while queue:
145 current_graph_module = queue.pop(0)
146 for node in current_graph_module.graph.nodes:
147 node_op(node)
148
149 control_flow_submodules = [
150 submodule
151 for _, submodule, _ in get_control_flow_submodules(current_graph_module)
152 ]
153 queue.extend(control_flow_submodules)

Callers 6

callMethod · 0.90
_verify_graph_matchFunction · 0.90
_apply_debug_handlesFunction · 0.90

Calls 1

Tested by

no test coverage detected