Skip to content

Commit e2909b9

Browse files
cccclaifacebook-github-bot
authored andcommitted
patch export delegate model flow
Summary: Some race landing with D47682172. Reviewed By: angelayi Differential Revision: D47876735 fbshipit-source-id: 428f589ad03766b23b838d2c12aa16b7e59e1f7c
1 parent 65c3f3e commit e2909b9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

examples/export/export_and_delegate.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ def export_compsite_module_with_lower_graph():
6767
m = AddMulModule().eval()
6868
m_inputs = m.get_random_inputs()
6969
edge = exir.capture(m, m_inputs, _CAPTURE_CONFIG).to_edge(_EDGE_COMPILE_CONFIG)
70-
print("Exported graph:\n", edge.graph)
70+
print("Exported graph:\n", edge.exported_program.graph)
7171

7272
# Lower AddMulModule to the demo backend
7373
print("Lowering to the demo backend...")
7474
lowered_graph = to_backend(
75-
BackendWithCompilerDemo.__name__, edge, m.get_compile_spec()
75+
BackendWithCompilerDemo.__name__, edge.exported_program, m.get_compile_spec()
7676
)
7777

7878
# Composite the lower graph with other module
@@ -92,9 +92,9 @@ def forward(self, *args):
9292
).to_edge(_EDGE_COMPILE_CONFIG)
9393

9494
# The graph module is still runnerable
95-
composited_edge.graph_module(*m_inputs)
95+
composited_edge.exported_program.graph_module(*m_inputs)
9696

97-
print("Lowered graph:\n", composited_edge.graph)
97+
print("Lowered graph:\n", composited_edge.exported_program.graph)
9898

9999
exec_prog = composited_edge.to_executorch()
100100
buffer = exec_prog.buffer
@@ -139,14 +139,14 @@ def get_random_inputs(self):
139139
edge = exir.capture(m, m.get_random_inputs(), _CAPTURE_CONFIG).to_edge(
140140
_EDGE_COMPILE_CONFIG
141141
)
142-
print("Exported graph:\n", edge.graph)
142+
print("Exported graph:\n", edge.exported_program.graph)
143143

144144
# Lower to backend_with_compiler_demo
145145
print("Lowering to the demo backend...")
146-
lower = to_backend(edge, AddMulPartitionerDemo)
147-
print("Lowered graph:\n", edge.graph)
146+
edge.exported_program = to_backend(edge.exported_program, AddMulPartitionerDemo)
147+
print("Lowered graph:\n", edge.exported_program.graph)
148148

149-
exec_prog = lower.to_executorch()
149+
exec_prog = edge.to_executorch()
150150
buffer = exec_prog.buffer
151151

152152
model_name = "partition_lowered_model"
@@ -173,11 +173,13 @@ def export_and_lower_the_whole_graph():
173173
edge = exir.capture(m, m.get_random_inputs(), _CAPTURE_CONFIG).to_edge(
174174
_EDGE_COMPILE_CONFIG
175175
)
176-
print("Exported graph:\n", edge.graph)
176+
print("Exported graph:\n", edge.exported_program.graph)
177177

178178
# Lower AddMulModule to the demo backend
179179
print("Lowering to the demo backend...")
180-
_ = to_backend(BackendWithCompilerDemo.__name__, edge, m.get_compile_spec())
180+
_ = to_backend(
181+
BackendWithCompilerDemo.__name__, edge.exported_program, m.get_compile_spec()
182+
)
181183

182184
# TODO(chenlai): emit the lowered graph
183185

0 commit comments

Comments
 (0)