Skip to content

Commit b8ff0a1

Browse files
angelayifacebook-github-bot
authored andcommitted
Fix ExportedProgram calls (#1985)
Summary: Pull Request resolved: #1985 D53075378 removed the ExportedProgram's `__call__` function, but some of the test failures were not caught by CI. Forward fixing the failures now Reviewed By: cccclai Differential Revision: D53813818 fbshipit-source-id: af20cb6d24da0d60fe0af0156e2c5c4082309643
1 parent ac9c121 commit b8ff0a1

File tree

6 files changed

+12
-13
lines changed

6 files changed

+12
-13
lines changed

backends/xnnpack/test/tester/tester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def run_artifact(self, inputs):
7878
if isinstance(self.artifact, ExportedProgram):
7979
return self.artifact(*inputs)
8080
else:
81-
return self.artifact.exported_program()(*inputs)
81+
return self.artifact.exported_program().module()(*inputs)
8282

8383
# Debug Tools for stages
8484
def artifact_str(self):
@@ -569,5 +569,5 @@ def dequant_shim(*args):
569569

570570
dequant_node.target = dequant_shim
571571

572-
output = program(*inputs)
572+
output = program.module()(*inputs)
573573
return output, scale

exir/program/test/test_program.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_edge_manager_transform(self):
184184
get_exported_programs(), get_config_methods()
185185
)
186186

187-
original_res = edge_manager.exported_program("forward")(
187+
original_res = edge_manager.exported_program("forward").module()(
188188
torch.ones(1), torch.ones(1)
189189
)
190190

@@ -234,7 +234,7 @@ def test_transform_dict_api(self):
234234
)
235235

236236
self.assertEqual(
237-
transformed_edge.exported_program("foo")(
237+
transformed_edge.exported_program("foo").module()(
238238
torch.ones(1),
239239
),
240240
torch.ones(1) + 1, # x + 1

exir/tests/TARGETS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ python_unittest(
428428
deps = [
429429
"//caffe2:torch",
430430
"//executorch/exir:lib",
431-
"//executorch/exir/passes:lib",
432431
],
433432
)
434433

exir/tests/test_delegate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def f(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
6161
FileCheck().check("lowered_module_0").check(
6262
"torch.ops.higher_order.executorch_call_delegate"
6363
).run(gm.graph_module.code)
64-
self.assertTrue(torch.allclose(orig_res, gm(*inputs)))
64+
self.assertTrue(torch.allclose(orig_res, gm.module()(*inputs)))
6565

6666
def test_to_backend(self) -> None:
6767
"""Check if we have patched a lowered module correctly (for delegation)"""
@@ -186,7 +186,7 @@ def forward(self, x, y):
186186
self.assertTrue(isinstance(node.args[0], list))
187187
self.assertEqual(len(node.args[0]), 1)
188188

189-
new_res = prog.exported_program()(*inputs)
189+
new_res = prog.exported_program().module()(*inputs)
190190
self.assertTrue(torch.allclose(new_res, orig_res))
191191

192192
def test_create_submodule_multiple_return(self) -> None:
@@ -246,7 +246,7 @@ def forward(self, x, y):
246246
self.assertTrue(isinstance(node.args[0], list))
247247
self.assertEqual(len(node.args[0]), 2)
248248

249-
new_res = prog.exported_program()(*inputs)
249+
new_res = prog.exported_program().module()(*inputs)
250250
self.assertTrue(torch.allclose(new_res, orig_res))
251251

252252
def test_create_submodule_list_return(self) -> None:
@@ -307,5 +307,5 @@ def forward(self, x, y):
307307
self.assertTrue(isinstance(node.args[0], list))
308308
self.assertEqual(len(node.args[0]), 2)
309309

310-
new_res = prog.exported_program()(*inputs)
310+
new_res = prog.exported_program().module()(*inputs)
311311
self.assertTrue(torch.allclose(new_res, orig_res))

exir/tests/test_memory_format_ops_pass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def memory_format_test_runner(self, test_set: MemoryFormatTestSet):
5656
).run(epm.exported_program().graph_module.code)
5757

5858
# check EdgeOp and the new BackendOp should behave the same
59-
expected = before(*test_set.sample_input)
60-
actual = epm.exported_program()(*test_set.sample_input)
59+
expected = before.module()(*test_set.sample_input)
60+
actual = epm.exported_program().module()(*test_set.sample_input)
6161
self.assertTrue(torch.allclose(actual, expected))
6262
self.assertEqual(
6363
self.is_channel_last(actual),

exir/tests/test_serde.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def check_ep(
3737
"""
3838
Checks if two graphs are equivalent
3939
"""
40-
orig_outputs = ep1(*inputs)
41-
loaded_outputs = ep2(*inputs)
40+
orig_outputs = ep1.module()(*inputs)
41+
loaded_outputs = ep2.module()(*inputs)
4242

4343
flat_orig_outputs, _ = pytree.tree_flatten(orig_outputs)
4444
flat_loaded_outputs, _ = pytree.tree_flatten(loaded_outputs)

0 commit comments

Comments
 (0)