aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_supported_operators.py
diff options
context:
space:
mode:
authorJohan Alfvén <johan.alfven@arm.com>2022-12-07 13:56:17 +0100
committerJohan Alfvén <johan.alfven@arm.com>2022-12-09 14:00:21 +0100
commitfaa4b7861317385ecd2357b7af9b90c6a5fbdd08 (patch)
treea7a6f98e8e17762a6a1b8f13358c71966d22cc05 /ethosu/vela/tflite_supported_operators.py
parent92689d5ad0dd19a3249e71dd0563731d4c6527c8 (diff)
downloadethos-u-vela-faa4b7861317385ecd2357b7af9b90c6a5fbdd08.tar.gz
MLBEDSW-7072: Added bias shape constraint
- Only 1D bias shape is supported - Modified test to reflect the constraint - Update SUPPORTED_OPS.md Signed-off-by: Johan Alfven <johan.alfven@arm.com> Change-Id: I00ae4b229d5f89512cb94f87f276af61cc66a6fd
Diffstat (limited to 'ethosu/vela/tflite_supported_operators.py')
-rw-r--r--ethosu/vela/tflite_supported_operators.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/ethosu/vela/tflite_supported_operators.py b/ethosu/vela/tflite_supported_operators.py
index aabe8130..ea39b478 100644
--- a/ethosu/vela/tflite_supported_operators.py
+++ b/ethosu/vela/tflite_supported_operators.py
@@ -234,6 +234,7 @@ class TFLiteSupportedOperators:
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_weights_type)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_weights_const)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_weights_limit)
+ self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_bias_shape)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_bias_type)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_bias_40bit)
# Transpose Conv specific checks:
@@ -275,6 +276,7 @@ class TFLiteSupportedOperators:
for op_type in TFLiteSupportedOperators.fc_vector_products:
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_weights_type)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_weights_const)
+ self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_bias_shape)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_bias_type)
self.specific_constraints[op_type].append(TFLiteSupportedOperators.constraint_bias_40bit)
@@ -474,6 +476,15 @@ class TFLiteSupportedOperators:
valid = limit <= cls.weights_limit
return valid, f"Tensor '{weights.name}' has the sum of weights: {limit}"
+ @staticmethod
+ def constraint_bias_shape(op):
+ "Optional Bias tensor must be of shape: 1D"
+ bias = op.bias
+ if bias:
+ valid = len(bias.shape) == 1
+ return valid, f"Tensor '{bias.name}' has shape: {bias.shape}"
+ return True, "Op has no bias tensor"
+
@classmethod
@docstring_format_args([list_formatter(supported_bias_dtypes)])
def constraint_bias_type(cls, op):