MLBEDSW-7408: MLCE: Crash when serialising model LSTM
- Added checking and reporting of missing operator attributes when
reading and writing TFLite file
- Added a TFLite semantic check to ensure that all required attribute
fields of builtin operators are read
- Added some sanity checks for RESHAPE operators that run on the
Ethos-U
- Stopped CPU operators from having their attributes modified
Change-Id: I05700681acdb09554f5945819717c08a9457295c
Signed-off-by: Tim Hall <tim.hall@arm.com>
diff --git a/ethosu/vela/tflite_supported_operators.py b/ethosu/vela/tflite_supported_operators.py
index 9ace321..95c7de3 100644
--- a/ethosu/vela/tflite_supported_operators.py
+++ b/ethosu/vela/tflite_supported_operators.py
@@ -847,13 +847,15 @@
valid = True
extra = []
- reshape_tens = op.inputs[1]
- if reshape_tens is not None:
- # constant inputs have either no driving operator or a const one
- # create a list of non-constant inputs
- if not (len(reshape_tens.ops) == 0 or reshape_tens.ops[0].type == Op.Const):
- valid = False
- extra.append(reshape_tens.name)
+ # if a reshape tensor is specified then it must be constant
+ if len(op.inputs) > 1:
+ reshape_tens = op.inputs[1]
+ if reshape_tens is not None:
+ # constant inputs have either no driving operator or a const one
+ # create a list of non-constant inputs
+ if not (len(reshape_tens.ops) == 0 or reshape_tens.ops[0].type == Op.Const):
+ valid = False
+ extra.append(reshape_tens.name)
extra = ", ".join(extra)
return valid, f"Op has non-const input(s): {extra}"