Skip to content

Commit 7e14c0e

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
remove exir.capture from test_rpc.py (#3102)
Summary: Pull Request resolved: #3102 title Reviewed By: tarun292 Differential Revision: D56259168 fbshipit-source-id: be80eeb616d6634c563ff3f1746cc6dc4aad0b6a
1 parent b341223 commit 7e14c0e

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

exir/backend/test/demos/rpc/test_rpc.py

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import torch
1010
from executorch import exir
11+
from executorch.exir import to_edge
1112
from executorch.exir.backend.backend_api import to_backend
1213
from executorch.exir.backend.test.demos.rpc.executor_backend_partitioner import (
1314
ExecutorBackendPartitioner,
@@ -20,6 +21,7 @@
2021
from executorch.extension.pybindings.portable_lib import ( # @manual
2122
_load_for_executorch_from_buffer,
2223
)
24+
from torch.export import export
2325
from torch.utils._pytree import tree_flatten
2426

2527
"""
@@ -101,16 +103,15 @@ def test_delegate_whole_program(self):
101103

102104
simple_net = self.get_a_simple_net()
103105
simple_net_input = simple_net.get_example_inputs()
104-
exported_program = exir.capture(
105-
simple_net, simple_net_input, exir.CaptureConfig()
106-
).to_edge(
107-
exir.EdgeCompileConfig(
106+
exported_program = to_edge(
107+
export(simple_net, simple_net_input),
108+
compile_config=exir.EdgeCompileConfig(
108109
_check_ir_validity=False,
109-
)
110+
),
110111
)
111112
# delegate the whole graph to the client executor
112113
lowered_module = to_backend(
113-
ExecutorBackend.__name__, exported_program.exported_program, []
114+
ExecutorBackend.__name__, exported_program.exported_program(), []
114115
)
115116

116117
class CompositeModule(torch.nn.Module):
@@ -123,11 +124,7 @@ def forward(self, *args):
123124

124125
composite_model = CompositeModule()
125126

126-
exec_prog = (
127-
exir.capture(composite_model, simple_net_input, exir.CaptureConfig())
128-
.to_edge()
129-
.to_executorch()
130-
)
127+
exec_prog = to_edge(export(composite_model, simple_net_input)).to_executorch()
131128

132129
executorch_module = _load_for_executorch_from_buffer(exec_prog.buffer)
133130

@@ -162,18 +159,14 @@ def forward(self, a, x, b):
162159
model = Model()
163160
inputs = (torch.ones(2, 2), torch.ones(2, 2), torch.ones(2, 2))
164161

165-
exported_program = exir.capture(model, inputs, exir.CaptureConfig()).to_edge()
162+
exported_program = to_edge(export(model, inputs))
166163

167164
# First lower to demo backend
168-
demo_backend_lowered = exported_program
169-
demo_backend_lowered.exported_program = to_backend(
170-
exported_program.exported_program, AddMulPartitionerDemo()
171-
)
165+
demo_backend_lowered = exported_program.to_backend(AddMulPartitionerDemo())
172166

173167
# Then lower to executor backend
174-
executor_backend_lowered = demo_backend_lowered
175-
executor_backend_lowered.exported_program = to_backend(
176-
demo_backend_lowered.exported_program, ExecutorBackendPartitioner()
168+
executor_backend_lowered = demo_backend_lowered.to_backend(
169+
ExecutorBackendPartitioner()
177170
)
178171

179172
prog_buffer = executor_backend_lowered.to_executorch()

0 commit comments

Comments
 (0)