19
19
import executorch .exir as exir
20
20
21
21
import torch
22
- from executorch .exir import ExecutorchBackendConfig
22
+ from executorch .exir import ExecutorchBackendConfig , to_edge
23
23
24
24
from executorch .exir .passes import MemoryPlanningPass , ToOutVarPass
25
25
from executorch .exir .print_program import pretty_print
30
30
)
31
31
32
32
from executorch .test .models .linear_model import LinearModel
33
+ from torch .export import export
33
34
34
35
35
36
def main () -> None :
@@ -38,21 +39,17 @@ def main() -> None:
38
39
trace_inputs = (torch .ones (2 , 2 , dtype = torch .float ),)
39
40
40
41
# Trace to FX Graph.
41
- exec_prog = (
42
- exir .capture (model , trace_inputs )
43
- .to_edge ()
44
- .to_executorch (
45
- config = ExecutorchBackendConfig (
46
- memory_planning_pass = MemoryPlanningPass (),
47
- to_out_var_pass = ToOutVarPass (),
48
- )
42
+ exec_prog = to_edge (export (model , trace_inputs )).to_executorch (
43
+ config = ExecutorchBackendConfig (
44
+ memory_planning_pass = MemoryPlanningPass (),
45
+ to_out_var_pass = ToOutVarPass (),
49
46
)
50
47
)
51
48
# Emit in-memory representation.
52
- pretty_print (exec_prog .program )
49
+ pretty_print (exec_prog .executorch_program )
53
50
54
51
# Serialize to flatbuffer.
55
- exec_prog .program .version = 0
52
+ exec_prog .executorch_program .version = 0
56
53
57
54
# Create test sets
58
55
method_test_cases : List [MethodTestCase ] = []
@@ -66,7 +63,6 @@ def main() -> None:
66
63
]
67
64
68
65
bundled_program = BundledProgram (exec_prog , method_test_suites )
69
- pretty_print (bundled_program )
70
66
71
67
bundled_program_flatbuffer = serialize_from_bundled_program_to_flatbuffer (
72
68
bundled_program
@@ -76,7 +72,7 @@ def main() -> None:
76
72
subprocess .run (["hg" , "root" ], stdout = subprocess .PIPE ).stdout .decode ().strip ()
77
73
)
78
74
with open (
79
- f"{ fbsource_base_path } /fbcode/executorch/test/models/linear_out_bundled_program.pte " ,
75
+ f"{ fbsource_base_path } /fbcode/executorch/test/models/linear_out_bundled_program.bpte " ,
80
76
"wb" ,
81
77
) as file :
82
78
file .write (bundled_program_flatbuffer )
0 commit comments