(
self,
config: Optional[ExecutorchBackendConfig] = None,
)
| 518 | print(self.exported_program.graph_module.graph) |
| 519 | |
| 520 | def to_executorch( |
| 521 | self, |
| 522 | config: Optional[ExecutorchBackendConfig] = None, |
| 523 | ) -> "ExecutorchProgram": |
| 524 | if not self.after_to_edge_passes: |
| 525 | raise RuntimeError("Must run to_edge before to_executorch.") |
| 526 | config = config or ExecutorchBackendConfig() |
| 527 | new_gm = self.exported_program.graph_module |
| 528 | for p in edge_to_executorch_passes(config): |
| 529 | new_gm_res = p(new_gm) |
| 530 | assert new_gm_res is not None |
| 531 | new_gm = new_gm_res.graph_module |
| 532 | |
| 533 | # This is tech debt on tech debt. memory planning pass inherits from some pass infra for GMs. |
| 534 | # This isnt enough info now so i cant use call I have to use some new function 'run'. |
| 535 | # Existing user passes dont use run so Im just cheating here because they dont need to work on mutable buffers yet. |
| 536 | # After exir.capture is gone I will clean up the memory planning infra to be consistent. |
| 537 | # Frankly all of exir has big code quality issues because of the migrations that need to be addressed. |
| 538 | new_gm_res = config.memory_planning_pass(new_gm) # pyre-ignore[29] |
| 539 | assert new_gm_res is not None |
| 540 | new_gm = new_gm_res.graph_module |
| 541 | new_prog = ExirExportedProgram( |
| 542 | copy.deepcopy(self.exported_program), self.after_to_edge_passes |
| 543 | ) |
| 544 | _copy_module(new_prog.exported_program.graph_module, new_gm) |
| 545 | executorch_prog = ExecutorchProgram( |
| 546 | new_prog, |
| 547 | emit_stacktrace=config.emit_stacktrace, |
| 548 | extract_delegate_segments=config.extract_delegate_segments, |
| 549 | segment_alignment=config.segment_alignment, |
| 550 | constant_tensor_alignment=config.constant_tensor_alignment, |
| 551 | delegate_alignment=config.delegate_alignment, |
| 552 | ) |
| 553 | executorch_prog.graph_module.meta.update(new_gm.meta) |
| 554 | executorch_prog.graph_module.meta.update( |
| 555 | self.exported_program.graph_module.meta |
| 556 | ) |
| 557 | return executorch_prog |
| 558 | |
| 559 | def __deepcopy__( |
| 560 | self, memo: Optional[Dict[int, Any]] = None |
nothing calls this directly
no test coverage detected