From eadb166072958febd7e222297d2a65bcf6063f01 Mon Sep 17 00:00:00 2001 From: Andreas Nevalainen Date: Tue, 1 Sep 2020 15:36:26 +0200 Subject: MLBEDSW-2885: Fix overflow from inf number Added check for inf numbers for all scales. Signed-off-by: Andreas Nevalainen Change-Id: I84fcae429be4869d8489f66bef26863c254104cd --- ethosu/vela/supported_operators.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ethosu/vela/supported_operators.py') diff --git a/ethosu/vela/supported_operators.py b/ethosu/vela/supported_operators.py index 9e9da8c6..0a1af829 100644 --- a/ethosu/vela/supported_operators.py +++ b/ethosu/vela/supported_operators.py @@ -192,6 +192,16 @@ class SupportedOperators: and op.attrs["fused_activation_function"] not in self.supported_fused_activations ): return False + + # check inf values + for tens in op.get_ifm_ifm2_weights_ofm(): + if (tens is not None) and ( + tens.quantization is not None) and ( + tens.quantization.scale_f32 is not None) and ( + np.isinf(tens.quantization.scale_f32).any()): + print("Warning:", op.type, "has inf valued tensor(s), placing on CPU") + return False + return True def check_convolution_restrictions(self, op): -- cgit v1.2.1