MLBEDSW-7884: Fix crash for RSQRT

- RSQRT is only defined for positive numbers and
therefore the zeropoint and actual input value
will have an impact

- Clamp the range to avoid crashing. As long as the actual
input is within valid range everything works. If the input
is not valid the reference will crash and not generating
any output

Change-Id: I1082b508d9cd85ad4b017e7b786cfff730585172
Signed-off-by: Johan Alfven <johan.alfven@arm.com>
diff --git a/ethosu/vela/lut.py b/ethosu/vela/lut.py
index e8759d9..ab440e6 100644
--- a/ethosu/vela/lut.py
+++ b/ethosu/vela/lut.py
@@ -295,9 +295,6 @@
     zp_in = op.ifm.quantization.zero_point
     zp_out = op.ofm.quantization.zero_point
 
-    # Make sure zero point is valid
-    assert (-128 - zp_in) >= 0, f"Rsqrt is only defined for positive values, zeropoint is {zp_in}"
-
     scale = np.double(1) / np.double(np.sqrt(ifm_scale) * ofm_scale)
     output_multiplier, output_shift = quantise_scale(scale)
 
@@ -314,7 +311,8 @@
         if x == -128:
             # Value already populated above
             continue
-        x_real = x - zp_in
+        # Rsqrt is only defined for positive values
+        x_real = max(0, x - zp_in)
         val = RSQRT_LUT[x_real]
         val = fp_math.multiply_by_quantized_multiplier(val, output_multiplier, output_shift - kshift) + zp_out
         lut_result = min(quantized_max, max(quantized_min, val))