From 3bbbed68f85c75806cd08b6453cdb678e47ceb2a Mon Sep 17 00:00:00 2001 From: "erik.andersson@arm.com" Date: Mon, 20 Dec 2021 14:14:16 +0100 Subject: 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 Change-Id: I63e9cd13cecf86d976c5750c727e218c334c32b5 --- ethosu/vela/tflite_model_semantic.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ethosu/vela/tflite_model_semantic.py b/ethosu/vela/tflite_model_semantic.py index b783bb74..3b7f248a 100644 --- a/ethosu/vela/tflite_model_semantic.py +++ b/ethosu/vela/tflite_model_semantic.py @@ -69,6 +69,7 @@ class TFLiteSemantic: 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) @@ -169,6 +170,17 @@ class TFLiteSemantic: 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" -- cgit v1.2.1