Bundled program contains all information needed to execute and verify the program on device. Public Attributes: method_test_suites: All test suites for verifying methods. executorch_program: ExecutorchProgram-like variable, containing the Program to be verified by method_te
| 31 | |
| 32 | |
| 33 | class BundledProgram: |
| 34 | """ |
| 35 | Bundled program contains all information needed to execute and verify the program on device. |
| 36 | |
| 37 | Public Attributes: |
| 38 | method_test_suites: All test suites for verifying methods. |
| 39 | executorch_program: ExecutorchProgram-like variable, containing the Program to be verified by method_test_suites, including |
| 40 | ExecutorchProgram, MultiMethodExecutorchProgram or ExecutorchProgramManager. |
| 41 | """ |
| 42 | |
| 43 | def __init__( |
| 44 | self, |
| 45 | executorch_program: Optional[ |
| 46 | Union[ |
| 47 | ExecutorchProgram, |
| 48 | ExecutorchProgramManager, |
| 49 | ] |
| 50 | ], |
| 51 | method_test_suites: Sequence[MethodTestSuite], |
| 52 | pte_file_path: Optional[str] = None, |
| 53 | ): |
| 54 | """Create BundledProgram by bundling the given program and method_test_suites together. |
| 55 | |
| 56 | Args: |
| 57 | executorch_program: The program to be bundled. |
| 58 | method_test_suites: The testcases for certain methods to be bundled. |
| 59 | pte_file_path: The path to pte file to deserialize program if executorch_program is not provided. |
| 60 | """ |
| 61 | if not executorch_program and not pte_file_path: |
| 62 | raise RuntimeError( |
| 63 | "Either executorch_program or pte_file_path must be provided" |
| 64 | ) |
| 65 | |
| 66 | if executorch_program and pte_file_path: |
| 67 | raise RuntimeError( |
| 68 | "Only one of executorch_program or pte_file_path can be used" |
| 69 | ) |
| 70 | |
| 71 | method_test_suites = sorted(method_test_suites, key=lambda x: x.method_name) |
| 72 | if executorch_program: |
| 73 | self._assert_valid_bundle(executorch_program, method_test_suites) |
| 74 | self.executorch_program: Optional[ |
| 75 | Union[ |
| 76 | ExecutorchProgram, |
| 77 | ExecutorchProgramManager, |
| 78 | ] |
| 79 | ] = executorch_program |
| 80 | self._pte_file_path: Optional[str] = pte_file_path |
| 81 | |
| 82 | self.method_test_suites = method_test_suites |
| 83 | |
| 84 | # This is the cache for bundled program in schema type. |
| 85 | # User should not access this field directly. Please Use `serialize_to_schema` function instead. |
| 86 | self._bundled_program_in_schema: Optional[bp_schema.BundledProgram] = None |
| 87 | |
| 88 | def serialize_to_schema(self) -> bp_schema.BundledProgram: |
| 89 | """Serialize the current Bundled Program into its schema format for further serialization..""" |
| 90 | # Return cached value if exists |
no outgoing calls