Returns the serialized ExecuTorch binary as a byte string. Note that the call to `buffer` may allocate a very large amount of contiguous memory, depending on the model size. If writing to a file, use `write_to_file` which won't incur additional copies.
(self)
| 624 | |
| 625 | @property |
| 626 | def buffer(self) -> bytes: |
| 627 | """Returns the serialized ExecuTorch binary as a byte string. |
| 628 | |
| 629 | Note that the call to `buffer` may allocate a very large amount of |
| 630 | contiguous memory, depending on the model size. If writing to a file, |
| 631 | use `write_to_file` which won't incur additional copies. |
| 632 | """ |
| 633 | # TODO(T181494963): update pybinding to remove buffer cache, which can consume large |
| 634 | # amounts of memory longer than necessary. |
| 635 | if self._buffer is None: |
| 636 | self._buffer = bytes(self._get_pte_data()) |
| 637 | return self._buffer |
| 638 | |
| 639 | @property |
| 640 | @experimental("This API is experimental and subject to change without notice.") |