Skip to content

Commit 1736571

Browse files
authored
Merge pull request pytorch#11 from cavusmustafa/remove_clone_ops
Remove clone ops
2 parents d3d3ae0 + e751726 commit 1736571

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

backends/openvino/partitioner.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def __init__(self):
3434

3535

3636
class OpenvinoOperatorsSupport(OperatorSupportBase):
37+
extended_support_dict = {
38+
"torch.ops.dim_order_ops._clone_dim_order.default": None,
39+
}
3740

3841
def __init__(
3942
self,
@@ -77,7 +80,9 @@ def is_node_supported(self, _, node: torch.fx.Node) -> bool:
7780
if node.name in self._enabled_ops_by_name:
7881
return True
7982

80-
supported_ops = OperatorSupport(options)._support_dict
83+
supported_ops = (
84+
OperatorSupport(options)._support_dict | self.extended_support_dict
85+
)
8186
if op_type == "getitem":
8287
return True
8388

backends/openvino/preprocess.py

Lines changed: 8 additions & 0 deletions
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,13 @@ 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+
transformed_ep = RemoveCloneOpsTransform()(edge_program.graph_module)
42+
43+
# Update the edge_program with the transformed graph
44+
if transformed_ep and transformed_ep.graph_module:
45+
edge_program._graph_module = transformed_ep.graph_module
46+
3947
input_names = edge_program.graph_signature.user_inputs
4048
args = []
4149
for node in edge_program.graph.nodes:

0 commit comments

Comments
 (0)