Skip to content

Commit d07fb5e

Browse files
lucylqfacebook-github-bot
authored andcommitted
remove duplicate deepcopy (#2550)
Summary: Program is deep copied inside backend_api before being passed to preprocess: https://www.internalfb.com/code/fbsource/fbcode/executorch/exir/backend/backend_api.py?lines=106 And then deepcopied again here. Reviewed By: cccclai Differential Revision: D55133796
1 parent 12b5324 commit d07fb5e

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

backends/xnnpack/xnnpack_preprocess.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# This source code is licensed under the BSD-style license found in the
55
# LICENSE file in the root directory of this source tree.
66

7-
import copy
8-
97
import logging
108
from dataclasses import dataclass
119
from typing import Dict, final, List
@@ -86,7 +84,6 @@ def preprocess(
8684
edge_program: ExportedProgram,
8785
compile_specs: List[CompileSpec],
8886
) -> PreprocessResult:
89-
ep = copy.deepcopy(edge_program)
9087
# Need to wrap EP here because xnnpack does addmm to linear
9188
# transforms. This makes resulting graph not aten compliant
9289
# as aten.linear is not a core aten op.
@@ -97,17 +94,17 @@ def preprocess(
9794
# EdgeDialectVerifier, but disable it.
9895
# TODO (task link) to implement NullVerifier or something similar
9996
ep = ExportedProgram(
100-
root=ep.graph_module,
101-
graph=ep.graph,
102-
graph_signature=ep.graph_signature,
103-
state_dict=ep.state_dict,
104-
range_constraints=ep.range_constraints,
105-
module_call_graph=copy.deepcopy(ep.module_call_graph),
106-
example_inputs=ep.example_inputs,
97+
root=edge_program.graph_module,
98+
graph=edge_program.graph,
99+
graph_signature=edge_program.graph_signature,
100+
state_dict=edge_program.state_dict,
101+
range_constraints=edge_program.range_constraints,
102+
module_call_graph=edge_program.module_call_graph,
103+
example_inputs=edge_program.example_inputs,
107104
verifier=EXIREdgeDialectVerifier(
108105
check_edge_ops=False, enable=False, class_only=True
109106
),
110-
constants=ep.constants,
107+
constants=edge_program.constants,
111108
)
112109

113110
passes = []

0 commit comments

Comments
 (0)