Returns a list of submodules used for control flow operations (torch.ops.higher_order.cond/map/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 grap
(
graph_module: torch.fx.GraphModule,
)
| 74 | |
| 75 | |
| 76 | def get_control_flow_submodules( |
| 77 | graph_module: torch.fx.GraphModule, |
| 78 | ) -> List[Tuple[str, torch.fx.GraphModule, torch.fx.Node]]: |
| 79 | """ |
| 80 | Returns a list of submodules used for control flow operations |
| 81 | (torch.ops.higher_order.cond/map/scan) that are in the given toplevel graph (does not look |
| 82 | into submodules). Specifically, the returned value is a list containing |
| 83 | tuples of (name of the submodule that's stored in the graph module, the |
| 84 | submodule itself, and the fx node that uses this submodule). |
| 85 | """ |
| 86 | return _get_control_flow_submodules( |
| 87 | graph_module, |
| 88 | { |
| 89 | torch.ops.higher_order.cond: [1, 2], |
| 90 | torch.ops.higher_order.map_impl: [0], |
| 91 | torch.ops.higher_order.scan: [0], # combine_fn is at arg index 0 |
| 92 | }, |
| 93 | ) |
| 94 | |
| 95 | |
| 96 | def get_cond_while_submodules( |