aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/tflite_supported_operators.py
diff options
context:
space:
mode:
authorJohan Alfven <johan.alfven@arm.com>2023-06-15 09:24:01 +0200
committerJohan Alfven <johan.alfven@arm.com>2023-06-16 16:01:05 +0200
commit85b77901b72865cc0071f294bd9177288c0bc4e3 (patch)
tree5bc2e96bc4521f2c1e8e33201d181cb5ec796caa /ethosu/vela/tflite_supported_operators.py
parent3e7157ba59f12aa0d277a9b3a7cb3f8a19267338 (diff)
downloadethos-u-vela-85b77901b72865cc0071f294bd9177288c0bc4e3.tar.gz
MLBEDSW-7709: MLCE: Crash when rewriting split op
- A crash occurred due to NoneType subscriptable error when rewriting a Slice op. The reason was that the Size tensor did not contain any data. - Added constraint pushing the Slice operator to the CPU if begin or size tensor are empty. - Added test to supported operators - Updated SUPPORTED_OPS.md Change-Id: Ide204cae24e5871f0e6ae1fdc98ac68d0ce4d3ae Signed-off-by: Johan Alfven <johan.alfven@arm.com>
Diffstat (limited to 'ethosu/vela/tflite_supported_operators.py')
-rw-r--r--ethosu/vela/tflite_supported_operators.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/ethosu/vela/tflite_supported_operators.py b/ethosu/vela/tflite_supported_operators.py
index a24eebc5..f965d2ba 100644
--- a/ethosu/vela/tflite_supported_operators.py
+++ b/ethosu/vela/tflite_supported_operators.py
@@ -331,6 +331,9 @@ class TFLiteSupportedOperators:
# Rsqrt specific checks
self.specific_constraints[Op.Rsqrt].append(TFLiteSupportedOperators.constraint_rsqrt_input_int8)
+ # Slice specific checks:
+ self.specific_constraints[Op.Slice].append(TFLiteSupportedOperators.constraint_slice_inputs_const)
+
def is_operator_supported(self, op):
ext_type = optype_to_builtintype(op.type)
if op.type not in TFLiteSupportedOperators.supported_operators:
@@ -942,3 +945,18 @@ class TFLiteSupportedOperators:
ifm_dtype = op.ifm.dtype
valid = ifm_dtype == DataType.int8
return valid, f"Op has ifm_dtype={ifm_dtype}"
+
+ @staticmethod
+ def constraint_slice_inputs_const(op):
+ "Begin and Size Input tensors must be constant"
+ valid = True
+ extra = []
+ _, begin, sizes = op.inputs
+ if begin.values is None:
+ valid = False
+ extra.append(f"Begin tensor '{begin.name}'")
+ if sizes.values is None:
+ valid = False
+ extra.append(f"Size tensor '{sizes.name}'")
+ extra = ", ".join(extra)
+ return valid, f"Op has non-constant tensors: {extra}"