1111 insert_dequant_node ,
1212 insert_quant_node ,
1313)
14- from executorch .backends .qualcomm .builders .node_visitor import dq_ops , q_dq_map , q_ops
14+ from executorch .backends .qualcomm .builders .node_visitor import (
15+ dq_ops ,
16+ q_ops ,
17+ to_dq_op ,
18+ to_q_op ,
19+ )
1520
1621from executorch .backends .qualcomm .builders .utils import is_graph_input , is_graph_output
1722
@@ -108,15 +113,15 @@ def preserve_io_qdq(self, graph_module: torch.fx.GraphModule) -> None:
108113 graph_module = graph_module ,
109114 input_node = n ,
110115 output_node = user ,
111- target = n .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ],
116+ target = to_q_op ( n .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ]) ,
112117 pop_quant_attrs = False ,
113118 )
114119 q_node .meta [QCOM_FALLBACK_NODE ] = True
115120 dq_node = insert_dequant_node (
116121 graph_module = graph_module ,
117122 input_node = q_node ,
118123 output_node = user ,
119- target = q_dq_map [ q_node .target ] ,
124+ target = to_dq_op ( q_node .target ) ,
120125 )
121126 dq_node .meta [QCOM_BYPASS_NODE ] = True
122127 elif (
@@ -131,15 +136,17 @@ def preserve_io_qdq(self, graph_module: torch.fx.GraphModule) -> None:
131136 graph_module = graph_module ,
132137 input_node = output_node ,
133138 output_node = getitem_node ,
134- target = output_node .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ],
139+ target = to_q_op (
140+ output_node .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ]
141+ ),
135142 pop_quant_attrs = False ,
136143 )
137144 q_node .meta [QCOM_BYPASS_NODE ] = True
138145 dq_node = insert_dequant_node (
139146 graph_module = graph_module ,
140147 input_node = q_node ,
141148 output_node = getitem_node ,
142- target = q_dq_map [ q_node .target ] ,
149+ target = to_dq_op ( q_node .target ) ,
143150 )
144151 dq_node .meta [QCOM_FALLBACK_NODE ] = True
145152
@@ -191,7 +198,7 @@ def insert_partition_qdq(
191198 graph_module = graph_module ,
192199 input_node = input_node ,
193200 output_node = node ,
194- target = input_node .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ],
201+ target = to_q_op ( input_node .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ]) ,
195202 pop_quant_attrs = False ,
196203 )
197204 for input_node in input_nodes
@@ -203,7 +210,7 @@ def insert_partition_qdq(
203210 graph_module = graph_module ,
204211 input_node = input_q_node ,
205212 output_node = node ,
206- target = q_dq_map [ input_q_node .target ] ,
213+ target = to_dq_op ( input_q_node .target ) ,
207214 )
208215 for input_q_node in input_q_nodes
209216 ]
@@ -232,17 +239,17 @@ def insert_partition_qdq(
232239 graph_module = graph_module ,
233240 input_node = output_node ,
234241 output_node = output_user_node ,
235- target = output_node .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ],
242+ target = to_q_op ( output_node .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ]) ,
236243 pop_quant_attrs = False ,
237244 )
238245 output_q_node .meta [QCOM_FALLBACK_NODE ] = True
239246 output_dq_node = insert_dequant_node (
240247 graph_module = graph_module ,
241248 input_node = output_q_node ,
242249 output_node = output_user_node ,
243- target = q_dq_map [
250+ target = to_dq_op (
244251 output_q_node .meta [QCOM_QUANT_ATTRS ][QCOM_ENCODING ]
245- ] ,
252+ ) ,
246253 )
247254 output_dq_node .meta [QCOM_BYPASS_NODE ] = True
248255 graph_module .graph .eliminate_dead_code ()
0 commit comments