Add executorch program data to the ETRecord after it has been created. This method allows users to add executorch program data they want to record to an existing ETRecord instance. The executorch program data includes debug handle map, delegate map, reference output
(
self,
executorch_program: Union[
ExecutorchProgram,
ExecutorchProgramManager,
BundledProgram,
],
)
| 347 | _add_module_to_graph_map(graph_map, module_name, export_module) |
| 348 | |
| 349 | def add_executorch_program( |
| 350 | self, |
| 351 | executorch_program: Union[ |
| 352 | ExecutorchProgram, |
| 353 | ExecutorchProgramManager, |
| 354 | BundledProgram, |
| 355 | ], |
| 356 | ) -> None: |
| 357 | """ |
| 358 | Add executorch program data to the ETRecord after it has been created. |
| 359 | |
| 360 | This method allows users to add executorch program data they want to record |
| 361 | to an existing ETRecord instance. The executorch program data includes debug handle map, |
| 362 | delegate map, reference outputs, and representative inputs that will be included |
| 363 | when the ETRecord is saved. |
| 364 | |
| 365 | Args: |
| 366 | executorch_program: The ExecuTorch program for this model returned by the call to |
| 367 | `to_executorch()` or the `BundledProgram` of this model. |
| 368 | |
| 369 | Raises: |
| 370 | RuntimeError: If executorch program data already exists in the ETRecord. |
| 371 | """ |
| 372 | # Check if executorch program data already exists |
| 373 | if ( |
| 374 | self._debug_handle_map is not None |
| 375 | or self._delegate_map is not None |
| 376 | or self._instruction_id_to_num_outs_map is not None |
| 377 | or self._reference_outputs is not None |
| 378 | or self._representative_inputs is not None |
| 379 | ): |
| 380 | raise RuntimeError( |
| 381 | "Executorch program data already exists in the ETRecord. " |
| 382 | "Cannot add executorch program data when it already exists." |
| 383 | ) |
| 384 | |
| 385 | # Process executorch program and extract data |
| 386 | ( |
| 387 | debug_handle_map, |
| 388 | delegate_map, |
| 389 | instruction_id_to_num_outs_map, |
| 390 | reference_outputs, |
| 391 | representative_inputs, |
| 392 | ) = _process_executorch_program(executorch_program) |
| 393 | |
| 394 | # Set the extracted data |
| 395 | self._debug_handle_map = debug_handle_map |
| 396 | self._delegate_map = delegate_map |
| 397 | self._instruction_id_to_num_outs_map = instruction_id_to_num_outs_map |
| 398 | self._reference_outputs = reference_outputs |
| 399 | self._representative_inputs = representative_inputs |
| 400 | |
| 401 | def add_exported_program( |
| 402 | self, |