MLBEDSW-4704: Crash when loading empty constant tensors
Fixed a crash caused by loading a network containing
operators with empty constant tensors.
This could occur when a branched network is split
before said branches have converged.
We now put the affected operator on the CPU.
Signed-off-by: erik.andersson@arm.com <erik.andersson@arm.com>
Change-Id: I63e9cd13cecf86d976c5750c727e218c334c32b5
diff --git a/ethosu/vela/tflite_model_semantic.py b/ethosu/vela/tflite_model_semantic.py
index b783bb7..3b7f248 100644
--- a/ethosu/vela/tflite_model_semantic.py
+++ b/ethosu/vela/tflite_model_semantic.py
@@ -69,6 +69,7 @@
self.generic_constraints.append(TFLiteSemantic.constraint_tens_quant_none_check)
self.generic_constraints.append(TFLiteSemantic.constraint_tens_quant_scale)
self.generic_constraints.append(TFLiteSemantic.constraint_quant_scale_inf)
+ self.generic_constraints.append(TFLiteSemantic.constraint_none_const_tensors)
# Setup specific constraints. Note: the order matters
self.specific_constraints = defaultdict(list)
@@ -170,6 +171,17 @@
return True
@staticmethod
+ def constraint_none_const_tensors(op):
+ "Constant tensors should not have NoneType-values"
+ valid = True
+ extra = ""
+ for tens in filter(None, op.inputs):
+ if len(tens.ops) > 0 and tens.ops[0].type == Op.Const and tens.values is None:
+ valid = False
+ extra = str(tens.name)
+ return valid, f"Unexpected None value for constant tensor: {extra}"
+
+ @staticmethod
def constraint_tens_no_dynamic(op):
"Input(s) and Output tensors must not be dynamic"
valid = True