Skip to content

Commit 1f7ad33

Browse files
Varun Purifacebook-github-bot
authored andcommitted
Move gen_test_files from AIBench to ExecuTorch examples (#1107)
Summary: Pull Request resolved: #1107 This script is useful to generate a sample ETRecord from the example models provided in the repo. This should help users explore the features of the ETrecord without needing to first export a .pte model. Reviewed By: Olivia-liu Differential Revision: D50521582 fbshipit-source-id: bad49adfd3dc106c1dcdc58bea0a26ec98022319
1 parent ec4868a commit 1f7ad33

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# Generate fixture files
8+
from pathlib import Path
9+
10+
import executorch.exir as exir
11+
from executorch.exir import ExecutorchBackendConfig
12+
13+
from executorch.exir.tests.models import BasicSinMax
14+
from executorch.sdk.etrecord import generate_etrecord
15+
from torch.export import export
16+
17+
18+
def get_module_path() -> Path:
19+
return Path(__file__).resolve().parents[0]
20+
21+
22+
def gen_etrecord():
23+
f = BasicSinMax()
24+
aten_dialect = export(
25+
f,
26+
f.get_random_inputs(),
27+
)
28+
edge_program = exir.to_edge(
29+
aten_dialect, compile_config=exir.EdgeCompileConfig(_check_ir_validity=False)
30+
)
31+
et_program = edge_program.to_executorch(ExecutorchBackendConfig(passes=[]))
32+
generate_etrecord(
33+
str(get_module_path()) + "/etrecord.bin",
34+
edge_dialect_program=edge_program,
35+
executorch_program=et_program,
36+
export_modules={
37+
"aten_dialect_output": aten_dialect,
38+
},
39+
)
40+
41+
42+
if __name__ == "__main__":
43+
gen_etrecord()

0 commit comments

Comments
 (0)