Returns a buffer containing the serialized ExecuTorch binary.
(
self,
extract_delegate_segments: bool = False,
segment_alignment: int = 128,
constant_tensor_alignment: Optional[int] = None,
delegate_alignment: Optional[int] = None,
memory_planning: MemoryPlanningPass = None, # pyre-fixme[9]
)
| 151 | |
| 152 | # TODO(chenlai): consolidate the seriailization config with serialize_to_flatbuffer api |
| 153 | def buffer( |
| 154 | self, |
| 155 | extract_delegate_segments: bool = False, |
| 156 | segment_alignment: int = 128, |
| 157 | constant_tensor_alignment: Optional[int] = None, |
| 158 | delegate_alignment: Optional[int] = None, |
| 159 | memory_planning: MemoryPlanningPass = None, # pyre-fixme[9] |
| 160 | ) -> bytes: |
| 161 | """ |
| 162 | Returns a buffer containing the serialized ExecuTorch binary. |
| 163 | """ |
| 164 | # TODO(T181463742): avoid calling bytes(..) which incurs large copies. |
| 165 | out = bytes( |
| 166 | _serialize_pte_binary( |
| 167 | pte_file=_PTEFile( |
| 168 | program=self.program(memory_planning=memory_planning), |
| 169 | named_data=self.named_data_store_output, |
| 170 | ), |
| 171 | extract_delegate_segments=extract_delegate_segments, |
| 172 | segment_alignment=segment_alignment, |
| 173 | constant_tensor_alignment=constant_tensor_alignment, |
| 174 | delegate_alignment=delegate_alignment, |
| 175 | ) |
| 176 | ) |
| 177 | return out |
| 178 | |
| 179 | # TODO(chenlai): re-consider recapture instead of manually constructing the program because |
| 180 | # the meta data construction is done manually. |