Added a lower bound for the valid range of shift
Very small quantization scales, below around 2^-31, would return
negative shift values.
Signed-off-by: Jacob Bohlin <jacob.bohlin@arm.com>
Change-Id: I4ca368284c097820f83e5ae53412a08c34516c7f
diff --git a/ethosu/vela/scaling.py b/ethosu/vela/scaling.py
index 7019c21..fcf054e 100644
--- a/ethosu/vela/scaling.py
+++ b/ethosu/vela/scaling.py
@@ -33,7 +33,7 @@
exponent_q31 = exponent - 31
shift = exponent_q31 * -1
- if shift >= (1 << 6):
+ if not (0 <= shift < (1 << 6)):
# Shift outside of valid range, set scale to 0
return 0, 16