Skip to content

Commit 7bb2c58

Browse files
Chakri Uddarajufacebook-github-bot
authored andcommitted
Add Manifold support for ModAI Manager (#3849)
Summary: Pull Request resolved: #3849 Add Manifold support for ModAI Manager Ensure EtRecord and torch.export use manifold file paths correctly so that they can write the data into manifold directly. Reviewed By: tarun292, navsud Differential Revision: D57936031 fbshipit-source-id: 06b850db723e58482f4d865199ece6ff9ab34be8
1 parent 5292bac commit 7bb2c58

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

examples/models/llama2/export_llama_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def _export_llama(modelname, args) -> LlamaEdgeManager: # noqa: C901
446446
# Generate ETRecord
447447
if edge_manager_copy:
448448
generate_etrecord(
449-
etrecord_path="etrecord.bin",
449+
et_record="etrecord.bin",
450450
edge_dialect_program=edge_manager_copy,
451451
executorch_program=builder.export_program,
452452
)

sdk/etrecord/_etrecord.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
# LICENSE file in the root directory of this source tree.
66

77
import json
8+
import os
89
import pickle
910
from dataclasses import dataclass
10-
from typing import Dict, List, Optional, Union
11+
from typing import BinaryIO, Dict, IO, List, Optional, Union
1112
from zipfile import BadZipFile, ZipFile
1213

1314
from executorch import exir
@@ -140,7 +141,7 @@ def _get_reference_outputs(
140141

141142

142143
def generate_etrecord(
143-
etrecord_path: str,
144+
et_record: Union[str, os.PathLike, BinaryIO, IO[bytes]],
144145
edge_dialect_program: Union[EdgeProgramManager, ExirExportedProgram],
145146
executorch_program: Union[
146147
ExecutorchProgram,
@@ -180,7 +181,10 @@ def generate_etrecord(
180181
None
181182
"""
182183

183-
etrecord_zip = ZipFile(etrecord_path, "w")
184+
if isinstance(et_record, (str, os.PathLike)):
185+
et_record = os.fspath(et_record) # pyre-ignore
186+
187+
etrecord_zip = ZipFile(et_record, "w")
184188
# Write the magic file identifier that will be used to verify that this file
185189
# is an etrecord when it's used later in the SDK tooling.
186190
etrecord_zip.writestr(ETRecordReservedFileNames.ETRECORD_IDENTIFIER, "")

0 commit comments

Comments
 (0)