(
tagged_graph_module: torch.fx.GraphModule,
partition_result: PartitionResult,
owning_program: ExportedProgram,
is_submodule: bool = False,
)
| 532 | |
| 533 | |
| 534 | def _create_partitions( |
| 535 | tagged_graph_module: torch.fx.GraphModule, |
| 536 | partition_result: PartitionResult, |
| 537 | owning_program: ExportedProgram, |
| 538 | is_submodule: bool = False, |
| 539 | ) -> Dict[str, List[torch.fx.Node]]: |
| 540 | backend_id_to_call_submodules = _create_partitions_in_graph_module( |
| 541 | tagged_graph_module, partition_result, owning_program, is_submodule |
| 542 | ) |
| 543 | |
| 544 | # Recursively partition and lower for submodules |
| 545 | for _, submod, _ in get_control_flow_submodules(tagged_graph_module): |
| 546 | nested_backend_id_to_call_submodules = _create_partitions( |
| 547 | submod, partition_result, owning_program, is_submodule=True |
| 548 | ) |
| 549 | for ( |
| 550 | backend_id, |
| 551 | nested_submodules, |
| 552 | ) in nested_backend_id_to_call_submodules.items(): |
| 553 | if backend_id not in backend_id_to_call_submodules: |
| 554 | backend_id_to_call_submodules[backend_id] = nested_submodules |
| 555 | else: |
| 556 | backend_id_to_call_submodules[backend_id].extend(nested_submodules) |
| 557 | |
| 558 | return backend_id_to_call_submodules |
| 559 | |
| 560 | |
| 561 | def lower_all_submodules_to_backend( |
no test coverage detected