Skip to content

Commit bbb2e24

Browse files
[executorch][native] Name residual ops when to_native cannot form one delegate (pytorch#23331)
This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: pytorch#23226 by @digantdesai ^ 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/digantdesai/106/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/digantdesai/106/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/digantdesai/105/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/digantdesai/106/orig Differential Revision: [D121704316](https://our.internmc.facebook.com/intern/diff/D121704316/) @diff-train-skip-merge Co-authored-by: Digant Desai <digantdesai@meta.com>
1 parent 599f264 commit bbb2e24

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎exir/native/native.py‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,10 @@ def to_native(
388388
from executorch.backends.native.partitioner import NativePartitioner
389389
from executorch.backends.native.passes import get_default_passes
390390
from executorch.exir import to_edge_transform_and_lower
391-
from executorch.exir.lowered_backend_module import get_lowered_submodules
391+
from executorch.exir.lowered_backend_module import (
392+
executorch_call_delegate,
393+
get_lowered_submodules,
394+
)
392395

393396
edge = to_edge_transform_and_lower(
394397
method_programs,
@@ -408,13 +411,22 @@ def to_native(
408411
method_program = edge.exported_program(method_name)
409412
lowered = get_lowered_submodules(method_program.graph_module)
410413
if len(lowered) != 1:
414+
residual_targets = sorted(
415+
{
416+
str(node.target)
417+
for node in method_program.graph_module.graph.nodes
418+
if node.op == "call_function"
419+
and node.target not in (executorch_call_delegate, operator.getitem)
420+
}
421+
)
411422
raise ValueError(
412423
f"to_native: method {method_name!r} lowered to {len(lowered)} "
413424
f"native delegates; exactly one is required. A method must be "
414425
f"wholly supported by the native backend: an identity method "
415426
f"produces none, and disconnected supported regions produce "
416-
f"several. See the README for this limitation of the current "
417-
f"implementation."
427+
"several. Residual operator targets: "
428+
f"{residual_targets}. See the README for this limitation of "
429+
"the current implementation."
418430
)
419431
module = lowered[0][1]
420432
_check_delegate_contract(

0 commit comments

Comments
 (0)