aboutsummaryrefslogtreecommitdiff
path: root/ethosu
diff options
context:
space:
mode:
Diffstat (limited to 'ethosu')
-rw-r--r--ethosu/vela/test/test_tflite_supported_operators.py2
-rw-r--r--ethosu/vela/tflite_supported_operators.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/ethosu/vela/test/test_tflite_supported_operators.py b/ethosu/vela/test/test_tflite_supported_operators.py
index d9b241fd..d091531d 100644
--- a/ethosu/vela/test/test_tflite_supported_operators.py
+++ b/ethosu/vela/test/test_tflite_supported_operators.py
@@ -62,7 +62,7 @@ def test_constraint_tens_quant_per_axis_not_supp():
def test_constraint_tens_quant_per_axis_is_supp():
op = testutil.create_op_with_quant_tensors(
- Op.Conv2DBias, [1, 1, 1, 3], [1, 1, 1, 3], weights_shape=[1, 1, 1, 3], bias_shape=[1, 1, 1, 3]
+ Op.Conv2DBias, [1, 1, 1, 3], [1, 1, 1, 3], weights_shape=[1, 1, 1, 3], bias_shape=[3]
)
op.attrs = {"stride_w": 1, "stride_h": 1}
assert support.is_operator_supported(op)
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):