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

Function get_scan_submodules

exir/graph_module.py:115–133  ·  view source on GitHub ↗

Returns a list of submodules used for scan operations (torch.ops.higher_order.scan) that are in the given toplevel graph (does not look into submodules). Specifically, the returned value is a list containing tuples of (name of the submodule that's stored in the graph module, the

(
    graph_module: torch.fx.GraphModule,
)

Source from the content-addressed store, hash-verified

113
114
115def get_scan_submodules(
116 graph_module: torch.fx.GraphModule,
117) -> List[Tuple[str, torch.fx.GraphModule, torch.fx.Node]]:
118 """
119 Returns a list of submodules used for scan operations
120 (torch.ops.higher_order.scan) that are in the given toplevel graph (does not look
121 into submodules). Specifically, the returned value is a list containing
122 tuples of (name of the submodule that's stored in the graph module, the
123 submodule itself, and the fx node that uses this submodule).
124
125 For scan, the combine_fn submodule is at argument index 0.
126 The scan operator signature is: scan(combine_fn, init, xs, additional_inputs)
127 """
128 return _get_control_flow_submodules(
129 graph_module,
130 {
131 torch.ops.higher_order.scan: [0],
132 },
133 )
134
135
136def bfs_trace_with_node_process(

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected