Skip to content

Commit 185c96a

Browse files
pytorchbotlucylq
andauthored
Use extension module for pybind (#13858)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #13717 by @lucylq ^ Please use this as the source of truth for the PR details, comments, and reviews ghstack PR base: https://github.com/pytorch/executorch/tree/gh/lucylq/102/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/lucylq/102/head Merge bot PR base: https://github.com/pytorch/executorch/tree/main Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/lucylq/102/orig @diff-train-skip-merge Co-authored-by: lucylq <[email protected]>
1 parent be65301 commit 185c96a

File tree

5 files changed

+81
-290
lines changed

5 files changed

+81
-290
lines changed

exir/backend/test/test_backends.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,16 @@ def forward(self, x):
319319
)
320320

321321
buff = exec_prog.buffer
322-
322+
executorch_module = _load_for_executorch_from_buffer(buff)
323323
# This line should raise an exception like
324324
# RuntimeError: failed with error 0x12
325-
_load_for_executorch_from_buffer(buff)
325+
executorch_module.run_method("forward")
326326

327327
@vary_segments
328328
def test_backend_with_compiler_out_of_range(self, extract_delegate_segments: bool):
329329
with self.assertRaisesRegex(
330330
RuntimeError,
331-
"loading method forward failed with error 0x12",
331+
"Failed to get method forward, error: 0x12",
332332
):
333333
self.run_model_in_unsupported_backend(
334334
extract_delegate_segments=extract_delegate_segments

exir/backend/test/test_backends_lifted.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,16 @@ def forward(self, x):
347347

348348
buff = exec_prog.buffer
349349

350+
executorch_module = _load_for_executorch_from_buffer(buff)
350351
# This line should raise an exception like
351352
# RuntimeError: failed with error 0x12
352-
_load_for_executorch_from_buffer(buff)
353+
executorch_module.run_method("forward")
353354

354355
@vary_segments
355356
def test_backend_with_compiler_out_of_range(self, extract_delegate_segments: bool):
356357
with self.assertRaisesRegex(
357358
RuntimeError,
358-
"loading method forward failed with error 0x12",
359+
"Failed to get method forward, error: 0x12",
359360
):
360361
self.run_model_in_unsupported_backend(
361362
extract_delegate_segments=extract_delegate_segments

exir/backend/test/test_compatibility.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ def forward(self, x):
6262
)
6363
)
6464

65+
executorch_module = _load_for_executorch_from_buffer(buff)
6566
# Throw runtime error with error code 0x30, meaning delegate is incompatible.
6667
with self.assertRaisesRegex(
6768
RuntimeError,
68-
"loading method forward failed with error 0x30",
69+
"Failed to get method forward, error: 0x30",
6970
):
70-
executorch_module = _load_for_executorch_from_buffer(buff)
71+
executorch_module.run_method("forward")
7172

7273
def test_compatibility_in_runtime_edge_program_manager(self):
7374
class SinModule(torch.nn.Module):
@@ -108,9 +109,10 @@ def forward(self, x):
108109
)
109110
)
110111

112+
executorch_module = _load_for_executorch_from_buffer(buff)
111113
# Throw runtime error with error code 0x30, meaning delegate is incompatible.
112114
with self.assertRaisesRegex(
113115
RuntimeError,
114-
"loading method forward failed with error 0x30",
116+
"Failed to get method forward, error: 0x30",
115117
):
116-
executorch_module = _load_for_executorch_from_buffer(buff)
118+
executorch_module.run_method("forward")

0 commit comments

Comments
 (0)