aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_model_semantic.py
diff options
context:
space:
mode:
authorFredrik Svedberg <fredrik.svedberg@arm.com>2022-09-07 16:01:15 +0200
committerFredrik Svedberg <fredrik.svedberg@arm.com>2022-09-12 10:10:14 +0000
commit701ba91870fa09e63d1ee3af6654689f78c138e8 (patch)
treee14f8e25aa2c7677e281426f65aaa7a5cf76e688 /ethosu/vela/tflite_model_semantic.py
parent9ae34556663d09cc3dff19e53e68b57c8c940565 (diff)
downloadethos-u-vela-701ba91870fa09e63d1ee3af6654689f78c138e8.tar.gz
MLBEDSW-6869 Improve LeakyRelu support
Added support for int16 LeakyRelu for negative alpha and alpha greater than one. Signed-off-by: Fredrik Svedberg <fredrik.svedberg@arm.com> Change-Id: I7f522ebfe014786d0a1d96172e75c7d9bdd76921
Diffstat (limited to 'ethosu/vela/tflite_model_semantic.py')
-rw-r--r--ethosu/vela/tflite_model_semantic.py12
1 files changed, 1 insertions, 11 deletions
diff --git a/ethosu/vela/tflite_model_semantic.py b/ethosu/vela/tflite_model_semantic.py
index 16ca2797..abda886c 100644
--- a/ethosu/vela/tflite_model_semantic.py
+++ b/ethosu/vela/tflite_model_semantic.py
@@ -161,9 +161,6 @@ class TFLiteSemantic:
self.specific_constraints[Op.StridedSlice].append(TFLiteSemantic.constraint_axis_masks)
self.specific_constraints[Op.StridedSlice].append(TFLiteSemantic.constraint_slice_ranges)
- # LeakyRelu specific checks:
- self.specific_constraints[Op.LeakyRelu].append(TFLiteSemantic.constraint_alpha_valid)
-
# FullyConnected specific checks:
self.specific_constraints[Op.FullyConnected].append(TFLiteSemantic.constraint_fc_output_2d)
self.specific_constraints[Op.FullyConnected].append(TFLiteSemantic.constraint_keep_dim_ifm_ofm)
@@ -175,6 +172,7 @@ class TFLiteSemantic:
# HardSwish specific checks:
self.specific_constraints[Op.HardSwish].append(TFLiteSemantic.constraint_input_8bit)
self.specific_constraints[Op.HardSwish].append(TFLiteSemantic.constraint_matching_in_out_types)
+
# Mean specific checks:
self.specific_constraints[Op.Mean].append(TFLiteSemantic.constraint_input_8bit)
self.specific_constraints[Op.Mean].append(TFLiteSemantic.constraint_mean_input_dims)
@@ -558,14 +556,6 @@ class TFLiteSemantic:
return valid, f"Op has ifm_shape={ifm_shape}, ifm2_shape={ifm2_shape} and ofm_shape={ofm_shape}"
@staticmethod
- def constraint_alpha_valid(op):
- "Alpha only allowed to be negative if IFM is int8 or uint8"
- alpha = op.attrs["alpha"]
- ifm_dtype = op.ifm.dtype
- valid = ifm_dtype == DataType.int8 or ifm_dtype == DataType.uint8 or alpha >= 0
- return valid, f"Op has alpha={alpha} and ifm_dtype={ifm_dtype} "
-
- @staticmethod
def constraint_keep_dim_ifm_ofm(op):
"The IFM and OFM must have the same number of dimensions if keep_num_dims is set to true"
valid = True