Skip to content

Commit 72331f5

Browse files
committed
Added Remove clone ops transformation to OpenVINO backend
1 parent d3d3ae0 commit 72331f5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

backends/openvino/preprocess.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from typing import final, List
1010

11+
from executorch.backends.transforms.remove_clone_ops import RemoveCloneOpsTransform
1112
from executorch.exir.backend.backend_details import (
1213
BackendDetails,
1314
ExportedProgram,
@@ -36,6 +37,14 @@ def preprocess(
3637
Returns:
3738
PreprocessResult: The result of preprocessing, including the compiled model bytes.
3839
"""
40+
# Apply RemoveCloneOpsTransform to eliminate unnecessary clone operations
41+
remove_clone_transform = RemoveCloneOpsTransform()
42+
transformed_result = remove_clone_transform(edge_program.graph_module)
43+
44+
# Update the edge_program with the transformed graph
45+
if transformed_result.graph_module is not None:
46+
edge_program._graph_module = transformed_result.graph_module
47+
3948
input_names = edge_program.graph_signature.user_inputs
4049
args = []
4150
for node in edge_program.graph.nodes:
@@ -47,7 +56,9 @@ def preprocess(
4756
compile_options[spec.key] = spec.value.decode()
4857

4958
compiled = openvino_compile(
50-
edge_program.module(), *args, options=compile_options
59+
edge_program.module(),
60+
*args,
61+
options=compile_options
5162
)
5263
model_bytes = compiled.export_model()
5364

0 commit comments

Comments
 (0)