2020Relu = exir_ops .edge .aten .relu .default
2121Sigmoid = exir_ops .edge .aten .sigmoid .default
2222Tanh = exir_ops .edge .aten .tanh .default
23+ Clone = exir_ops .edge .aten .clone .default
2324CloneDimOrder = exir_ops .edge .dim_order_ops ._clone_dim_order .default
2425
2526
@@ -70,29 +71,29 @@ def _is_quantize(node_: Node) -> bool:
7071
7172class MoveLeadingAuxiliaryOperatorIntoSeparateQDQClusterPass (NeutronEdgePass ):
7273 """
73- │
74- ┌─────▼──────┐
75- │ │ dequantize │
76- ┌─────▼──────┐ └─────┬──────┘
77- │ dequantize │ ┌─────▼──────┐
78- └─────┬──────┘ │ <aux_node> │
79- ┌─────▼──────┐ └─────┬──────┘
80- │ <aux_node> │ ┌────▼─────┐ ┐
81- └─────┬──────┘ │ quantize │ │
82- ┌──────────▼──────────┐ replaced with └────┬─────┘ │
83- ⋯ ┤ <main_cluster_node> ├⋯ ──────────────► │ │ newly added nodes
84- └──────────┬──────────┘ ┌─────▼──────┐ │
85- ▼ │ dequantize │ │
86- ⋮ └─────┬──────┘ ┘
87- ┌────▼─────┐ ┌──────────▼──────────┐
88- │ quantize │ ⋯ ┤ <main_cluster_node> ├⋯
89- └────┬─────┘ └──────────┬──────────┘
90- ▼ ▼
91- ⋮
92- ┌────▼─────┐
93- │ quantize │
94- └────┬─────┘
95- ▼
74+ │
75+ ┌─────▼──────┐
76+ │ │ dequantize │
77+ ┌─────▼──────┐ └─────┬──────┘
78+ │ dequantize │ ┌─────▼──────┐
79+ └─────┬──────┘ │ <aux_node> │
80+ ┌─────▼──────┐ └─────┬──────┘
81+ │ <aux_node> │ ┌────▼─────┐ ┐
82+ └─────┬──────┘ │ quantize │ │
83+ ┌──────────▼──────────┐ replaced with └────┬─────┘ │
84+ ... ┤ <main_cluster_node> ├... ──────────────► │ │ newly added nodes
85+ └──────────┬──────────┘ ┌─────▼──────┐ │
86+ ▼ │ dequantize │ │
87+ . └─────┬──────┘ ┘
88+ ┌────▼─────┐ ┌──────────▼──────────┐
89+ │ quantize │ ... ┤ <main_cluster_node> ├...
90+ └────┬─────┘ └──────────┬──────────┘
91+ ▼ ▼
92+ .
93+ ┌────▼─────┐
94+ │ quantize │
95+ └────┬─────┘
96+ ▼
9697 """
9798
9899 # Dictionary mapping main cluster nodes to auxiliary nodes, for which this optimization will be applied.
@@ -103,9 +104,7 @@ class MoveLeadingAuxiliaryOperatorIntoSeparateQDQClusterPass(NeutronEdgePass):
103104 MM : [
104105 ViewCopy ,
105106 ],
106- ViewCopy : [
107- CloneDimOrder ,
108- ],
107+ ViewCopy : [Clone , CloneDimOrder ],
109108 }
110109
111110 def run (self , graph_module : torch .fx .GraphModule ) -> PassResult :
@@ -156,28 +155,28 @@ def run(self, graph_module: torch.fx.GraphModule) -> PassResult:
156155
157156class MoveTrailingAuxiliaryOperatorIntoSeparateQDQClusterPass (NeutronEdgePass ):
158157 """
159- │
160- ┌─────▼──────┐
161- │ │ dequantize │
162- ┌─────▼──────┐ └─────┬──────┘
163- │ dequantize │ ⋮
164- └─────┬──────┘ ┌──────────▼──────────┐
165- ▼ ⋯ ┤ <main_cluster_node> ├⋯
166- ⋮ └──────────┬──────────┘
167- ┌──────────▼──────────┐ replaced with ┌────▼─────┐ ┐
168- ⋯ ┤ <main_cluster_node> ├⋯ ──────────────► │ quantize │ │
169- └──────────┬──────────┘ └────┬─────┘ │
170- ┌─────▼──────┐ │ │ newly added nodes
171- │ <aux_node> │ ┌─────▼──────┐ │
172- └─────┬──────┘ │ dequantize │ │
173- ┌────▼─────┐ └─────┬──────┘ ┘
174- │ quantize │ ┌─────▼──────┐
175- └────┬─────┘ │ <aux_node> │
176- ▼ └─────┬──────┘
177- ┌────▼─────┐
178- │ quantize │
179- └────┬─────┘
180- ▼
158+ │
159+ ┌─────▼──────┐
160+ │ │ dequantize │
161+ ┌─────▼──────┐ └─────┬──────┘
162+ │ dequantize │ .
163+ └─────┬──────┘ ┌──────────▼──────────┐
164+ ▼ ... ┤ <main_cluster_node> ├...
165+ . └──────────┬──────────┘
166+ ┌──────────▼──────────┐ replaced with ┌────▼─────┐ ┐
167+ ... ┤ <main_cluster_node> ├... ──────────────► │ quantize │ │
168+ └──────────┬──────────┘ └────┬─────┘ │
169+ ┌─────▼──────┐ │ │ newly added nodes
170+ │ <aux_node> │ ┌─────▼──────┐ │
171+ └─────┬──────┘ │ dequantize │ │
172+ ┌────▼─────┐ └─────┬──────┘ ┘
173+ │ quantize │ ┌─────▼──────┐
174+ └────┬─────┘ │ <aux_node> │
175+ ▼ └─────┬──────┘
176+ ┌────▼─────┐
177+ │ quantize │
178+ └────┬─────┘
179+ ▼
181180 """
182181
183182 # Dictionary mapping main cluster nodes to auxiliary nodes, for which this optimization will be applied.
@@ -202,6 +201,7 @@ class MoveTrailingAuxiliaryOperatorIntoSeparateQDQClusterPass(NeutronEdgePass):
202201 Sigmoid ,
203202 Tanh ,
204203 ],
204+ ViewCopy : [Clone , CloneDimOrder ],
205205 }
206206
207207 def run (self , graph_module : torch .fx .GraphModule ) -> PassResult :
0 commit comments