Skip to content

Commit 23cfcaa

Browse files
angelayifacebook-github-bot
authored andcommitted
Remove setter for graph_module
Summary: X-link: pytorch/pytorch#106651 The ExportedProgram should be immutable Reviewed By: zhxchen17 Differential Revision: D48086375 fbshipit-source-id: c5da030f0fd9ed4fa78449161e9d6e1b57b32645
1 parent 950ce1b commit 23cfcaa

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

backends/xnnpack/test/tester/tester.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def run(
152152
) -> None:
153153
prepared = prepare_pt2e(artifact.exported_program.graph_module, self.quantizer)
154154
converted = convert_pt2e(prepared)
155-
artifact.exported_program.graph_module = converted
155+
artifact.exported_program._graph_module = converted
156156
self.converted_program = artifact
157157

158158
@property

exir/backend/backend_api.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,16 @@ def to_backend(
287287
tagged_graph_module, partitioner_instance, edge_program
288288
)
289289

290-
edge_program.graph_module = tagged_graph_module
291-
return edge_program
290+
return ExportedProgram(
291+
tagged_graph_module,
292+
tagged_graph_module.graph,
293+
copy.deepcopy(edge_program.graph_signature),
294+
copy.deepcopy(edge_program.call_spec),
295+
edge_program.state_dict,
296+
copy.deepcopy(edge_program.range_constraints),
297+
copy.deepcopy(edge_program.equality_constraints),
298+
copy.deepcopy(edge_program.module_call_graph),
299+
)
292300

293301

294302
def to_backend_multiple(

0 commit comments

Comments
 (0)