@@ -176,17 +176,45 @@ def __init__(self, model, subgraph, exp_tab):
176
176
def check_unsupported_ops (self ):
177
177
"""Check unsupported TFLite ops in our converter."""
178
178
unsupported_ops_set = set ()
179
-
179
+ dynamic_range_ops_set = set ()
180
180
for op_idx in range (self .subgraph .OperatorsLength ()):
181
181
op = self .subgraph .Operators (op_idx )
182
182
op_code_str = self .get_op_code_str (op )
183
183
if op_code_str not in self .convert_map :
184
184
unsupported_ops_set .add (op_code_str )
185
+ continue
186
+
187
+ # Trying to exclude "dynamic range quantization" optimized ops as not supported in TVM
188
+ qnn_in_cnt = len (
189
+ [_ .qnn_params for _ in self .get_input_tensors (op )[0 :1 ] if _ .qnn_params is not None ]
190
+ )
191
+ qnn_weight_cnt = len (
192
+ [_ .qnn_params for _ in self .get_input_tensors (op )[1 :] if _ .qnn_params is not None ]
193
+ )
194
+ qnn_out_cnt = len (
195
+ [_ .qnn_params for _ in self .get_output_tensors (op ) if _ .qnn_params is not None ]
196
+ )
197
+
198
+ if qnn_in_cnt == 0 and qnn_out_cnt == 0 and qnn_weight_cnt > 0 :
199
+ dynamic_range_ops_set .add (op_code_str )
200
+
201
+ raise_msg = ""
185
202
186
203
if unsupported_ops_set :
187
- msg = "The following operators are not supported in frontend " "TFLite: {}"
204
+ msg = "The following operators are not supported in frontend " "TFLite: {}\n "
188
205
ops = str (list (unsupported_ops_set )).strip ("[,]" )
189
- raise tvm .error .OpNotImplemented (msg .format (ops ))
206
+ raise_msg += msg .format (ops )
207
+
208
+ if dynamic_range_ops_set :
209
+ msg = (
210
+ "The following operators are likely to have dynamic range quantization: {}. "
211
+ "If you are running an optimized graph, please turn off dynamic range quantization "
212
+ "or use full integer quantization"
213
+ )
214
+ raise_msg += msg .format (str (list (dynamic_range_ops_set )).strip ("[,]" ))
215
+
216
+ if len (raise_msg ) > 0 :
217
+ raise tvm .error .OpNotImplemented (raise_msg )
190
218
191
219
def convert_op_to_relay (self ):
192
220
"""Convert TFLite ops to relay ops"""
0 commit comments