diff options
author | erik.andersson@arm.com <erik.andersson@arm.com> | 2021-12-20 14:14:16 +0100 |
---|---|---|
committer | erik.andersson@arm.com <erik.andersson@arm.com> | 2021-12-23 10:11:46 +0100 |
commit | 3bbbed68f85c75806cd08b6453cdb678e47ceb2a (patch) | |
tree | 0b454266118d6a1196a5b997cb5b961684bc51ab | |
parent | 91c5a14059f24951f5b46cb448c60269723e0b16 (diff) | |
download | ethos-u-vela-3bbbed68f85c75806cd08b6453cdb678e47ceb2a.tar.gz |
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
-rw-r--r-- | ethosu/vela/tflite_model_semantic.py | 12 |
1 files changed, 12 insertions, 0 deletions
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) @@ -170,6 +171,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" valid = True |