aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_model_semantic.py
diff options
context:
space:
mode:
authorFredrik Svedberg <fredrik.svedberg@arm.com>2022-07-06 14:54:12 +0200
committerFredrik Svedberg <fredrik.svedberg@arm.com>2022-07-15 13:20:47 +0000
commit1156317a8a8df1bc0c25a54db8475d84495f1a79 (patch)
treea34f60c1d874bcac6e65052e39fca1608f3b72fb /ethosu/vela/tflite_model_semantic.py
parent93f492bae9c4dd16a1f64b851b237263695ee03e (diff)
downloadethos-u-vela-1156317a8a8df1bc0c25a54db8475d84495f1a79.tar.gz
MLBEDSW-6703 Add SHAPE operator to supported operators
Added SHAPE operator to the supported operators report. Updated the constraints for QUANTIZE and SHAPE operator. Also fixed RESHAPE consuming statically optimised shape. Signed-off-by: Fredrik Svedberg <fredrik.svedberg@arm.com> Change-Id: I1d964d602d3f361a0f16dae8133197280dd84c48
Diffstat (limited to 'ethosu/vela/tflite_model_semantic.py')
-rw-r--r--ethosu/vela/tflite_model_semantic.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/ethosu/vela/tflite_model_semantic.py b/ethosu/vela/tflite_model_semantic.py
index 9408e0ce..16ca2797 100644
--- a/ethosu/vela/tflite_model_semantic.py
+++ b/ethosu/vela/tflite_model_semantic.py
@@ -76,7 +76,7 @@ class TFLiteSemantic:
)
binary_elem_wise_main_ops = binary_elem_wise_min_max_ops | binary_elem_wise_add_mul_sub | binary_elem_wise_shift_ops
elem_wise_main_ops = binary_elem_wise_main_ops | unary_elem_wise_main_ops
- shapeless_input_ops = binary_elem_wise_main_ops | set((Op.Split, Op.SplitV, Op.Mean, Op.ExpandDims))
+ shapeless_input_ops = binary_elem_wise_main_ops | set((Op.Split, Op.SplitV, Op.Mean, Op.ExpandDims, Op.Quantize))
reshape_ops = set(
(
Op.Reshape,
@@ -214,13 +214,10 @@ class TFLiteSemantic:
generic_constraints_exclude_list = {
Op.Shape: [
TFLiteSemantic.constraint_tens_quant_none_check,
- TFLiteSemantic.constraint_tens_quant_scale,
- TFLiteSemantic.constraint_quant_scale_inf,
],
Op.Quantize: [
TFLiteSemantic.constraint_tens_no_dynamic,
TFLiteSemantic.constraint_tens_output_scalar,
- TFLiteSemantic.constraint_tens_input_scalar,
],
}
return generic_constraints_exclude_list
@@ -314,7 +311,11 @@ class TFLiteSemantic:
extra = []
tensors = [tens for tens in op.get_ifm_ifm2_weights_ofm() if tens]
for tens in tensors:
- if (tens.quantization.scale_f32 is not None) and np.isinf(tens.quantization.scale_f32).any():
+ if (
+ tens.quantization
+ and tens.quantization.scale_f32 is not None
+ and np.isinf(tens.quantization.scale_f32).any()
+ ):
valid = False
extra.append(f"Tensor '{tens.name}' has quantization scale: {tens.quantization.scale_f32}")
return valid, ", ".join(extra)