|
19 | 19 | from executorch.devtools.bundled_program.version import BUNDLED_PROGRAM_SCHEMA_VERSION
|
20 | 20 |
|
21 | 21 | from executorch.exir import ExecutorchProgram, ExecutorchProgramManager
|
22 |
| -from executorch.exir._serialize import _deserialize_pte_binary, _serialize_pte_binary |
23 | 22 | from executorch.exir.tensor import get_scalar_type, scalar_type_enum, TensorSpec
|
24 | 23 |
|
25 | 24 | # pyre-ignore
|
@@ -92,14 +91,6 @@ def serialize_to_schema(self) -> bp_schema.BundledProgram:
|
92 | 91 | if self._bundled_program_in_schema is not None:
|
93 | 92 | return self._bundled_program_in_schema
|
94 | 93 |
|
95 |
| - if self.executorch_program: |
96 |
| - program = self._extract_program(self.executorch_program) |
97 |
| - else: |
98 |
| - assert self._pte_file_path is not None |
99 |
| - with open(self._pte_file_path, "rb") as f: |
100 |
| - p_bytes = f.read() |
101 |
| - program = _deserialize_pte_binary(p_bytes) |
102 |
| - |
103 | 94 | bundled_method_test_suites: List[bp_schema.BundledMethodTestSuite] = []
|
104 | 95 |
|
105 | 96 | # Emit data and metadata of bundled tensor
|
@@ -149,8 +140,13 @@ def serialize_to_schema(self) -> bp_schema.BundledProgram:
|
149 | 140 | )
|
150 | 141 | )
|
151 | 142 |
|
152 |
| - # TODO(T181463742): avoid calling bytes(..) which may incur large copies. |
153 |
| - program_bytes: bytes = bytes(_serialize_pte_binary(program)) |
| 143 | + if self.executorch_program: |
| 144 | + program_bytes = self.executorch_program.buffer |
| 145 | + else: |
| 146 | + assert self._pte_file_path is not None |
| 147 | + with open(self._pte_file_path, "rb") as f: |
| 148 | + program_bytes = f.read() |
| 149 | + |
154 | 150 | self._bundled_program_in_schema = bp_schema.BundledProgram(
|
155 | 151 | version=BUNDLED_PROGRAM_SCHEMA_VERSION,
|
156 | 152 | method_test_suites=bundled_method_test_suites,
|
|
0 commit comments