Skip to content

Commit 87fc139

Browse files
Gasoonjiafacebook-github-bot
authored andcommitted
equip the first partition with same example input as original graph (pytorch#14454)
Summary: This diff equips the partitioned submodules example inputs. More specific, if the submodule starts from and covers all original export program's input, its example inputs should be the same as original export program's. Otherwise, the example inputs should be None. The example inputs is essential for aoti-driven backends for further compile. Reviewed By: larryliu0820 Differential Revision: D82865677
1 parent 99e4fbe commit 87fc139

File tree

4 files changed

+460
-0
lines changed

4 files changed

+460
-0
lines changed

exir/backend/backend_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,8 @@ def to_backend(
720720
fake_edge_program = copy.deepcopy(edge_program)
721721
partitioner_result = partitioner_instance(fake_edge_program)
722722
tagged_exported_program = partitioner_result.tagged_exported_program
723+
tagged_exported_program.example_inputs = edge_program.example_inputs
724+
723725
method_to_tagged_exported_program[method_name] = tagged_exported_program
724726

725727
# Check that the partitioner did not modify the original graph

exir/backend/test/TARGETS

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,3 +458,21 @@ python_unittest(
458458
"//executorch/exir/backend/canonical_partitioners:group_partitioner_lib",
459459
],
460460
)
461+
462+
python_unittest(
463+
name = "test_example_input_of_submodule",
464+
srcs = [
465+
"test_submodule_example_inputs.py",
466+
],
467+
deps = [
468+
"//caffe2:torch",
469+
"//executorch/exir:lib",
470+
"//executorch/exir:lowered_backend_module",
471+
"//executorch/exir/backend:backend_details",
472+
"//executorch/exir/backend:compile_spec_schema",
473+
"//executorch/exir/backend:partitioner",
474+
"//executorch/exir/backend/test/demos/rpc:executor_backend_preprocess",
475+
"//executorch/exir/backend:utils",
476+
"//executorch/exir/dialects:lib",
477+
],
478+
)

0 commit comments

Comments
 (0)