MLBEDSW-2885: Fix overflow from inf number
Added check for inf numbers for all scales.
Signed-off-by: Andreas Nevalainen <andreas.nevalainen@arm.com>
Change-Id: I84fcae429be4869d8489f66bef26863c254104cd
diff --git a/ethosu/vela/supported_operators.py b/ethosu/vela/supported_operators.py
index 9e9da8c..0a1af82 100644
--- a/ethosu/vela/supported_operators.py
+++ b/ethosu/vela/supported_operators.py
@@ -192,6 +192,16 @@
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):