|  | 
| 47 | 47 | ) | 
| 48 | 48 | from executorch.backends.arm.test.runner_utils import ( | 
| 49 | 49 |     dbg_tosa_fb_to_json, | 
| 50 |  | -    get_elf_path, | 
| 51 | 50 |     get_output_quantization_params, | 
| 52 |  | -    get_target_board, | 
| 53 |  | -    run_target, | 
| 54 | 51 |     TosaReferenceModelDispatch, | 
| 55 | 52 | ) | 
| 56 | 53 | 
 | 
|  | 
| 97 | 94 | from torch.export.graph_signature import ExportGraphSignature, InputSpec, OutputSpec | 
| 98 | 95 | from torch.fx import Graph | 
| 99 | 96 | from torch.utils._pytree import tree_flatten | 
|  | 97 | +from executorch.backends.arm.test.tester.serialize import Serialize | 
| 100 | 98 | 
 | 
| 101 | 99 | 
 | 
| 102 | 100 | logger = logging.getLogger(__name__) | 
| @@ -184,44 +182,6 @@ def run( | 
| 184 | 182 |             generate_etrecord=generate_etrecord, | 
| 185 | 183 |         ) | 
| 186 | 184 | 
 | 
| 187 |  | - | 
| 188 |  | -class Serialize(tester.Serialize): | 
| 189 |  | -    def __init__(self, compile_spec: list[CompileSpec], timeout): | 
| 190 |  | -        super().__init__() | 
| 191 |  | -        self.timeout = timeout | 
| 192 |  | -        self.executorch_program_manager: ExecutorchProgramManager | None | 
| 193 |  | -        self.compile_spec = compile_spec | 
| 194 |  | - | 
| 195 |  | -    def run(self, artifact: ExecutorchProgramManager, inputs=None) -> None: | 
| 196 |  | -        super().run(artifact, inputs) | 
| 197 |  | -        # Keep the entire ExecutorchProgramManager for execution. | 
| 198 |  | -        self.executorch_program_manager = artifact | 
| 199 |  | - | 
| 200 |  | -    def run_artifact(self, inputs): | 
| 201 |  | -        if self.executorch_program_manager is None: | 
| 202 |  | -            raise RuntimeError( | 
| 203 |  | -                "Tried running artifact from Serialize stage without running the stage." | 
| 204 |  | -            ) | 
| 205 |  | -        inputs_flattened, _ = tree_flatten(inputs) | 
| 206 |  | -        intermediate_path = get_intermediate_path(self.compile_spec) | 
| 207 |  | -        target_board = get_target_board(self.compile_spec) | 
| 208 |  | -        elf_path = get_elf_path(target_board) | 
| 209 |  | - | 
| 210 |  | -        if not os.path.exists(elf_path): | 
| 211 |  | -            raise FileNotFoundError( | 
| 212 |  | -                f"Did not find build arm_executor_runner in path {elf_path}, run setup_testing.sh?" | 
| 213 |  | -            ) | 
| 214 |  | - | 
| 215 |  | -        return run_target( | 
| 216 |  | -            self.executorch_program_manager, | 
| 217 |  | -            inputs_flattened, | 
| 218 |  | -            intermediate_path, | 
| 219 |  | -            target_board, | 
| 220 |  | -            elf_path, | 
| 221 |  | -            self.timeout, | 
| 222 |  | -        ) | 
| 223 |  | - | 
| 224 |  | - | 
| 225 | 185 | class ToExecutorch(tester.ToExecutorch): | 
| 226 | 186 |     def run_artifact(self, inputs): | 
| 227 | 187 |         with TosaReferenceModelDispatch(): | 
| @@ -423,7 +383,7 @@ def serialize( | 
| 423 | 383 |         self, serialize_stage: Optional[Serialize] = None, timeout: int = 480 | 
| 424 | 384 |     ): | 
| 425 | 385 |         if serialize_stage is None: | 
| 426 |  | -            serialize_stage = Serialize(self.compile_spec, timeout) | 
|  | 386 | +            serialize_stage = Serialize(compile_spec=self.compile_spec, module=self.original_module, timeout=timeout) | 
| 427 | 387 |         assert ( | 
| 428 | 388 |             get_intermediate_path(self.compile_spec) is not None | 
| 429 | 389 |         ), "Can't dump serialized file when compile specs do not contain an artifact path." | 
|  | 
0 commit comments