aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Bohlin <jacob.bohlin@arm.com>2020-08-20 15:51:37 +0200
committerJacob Bohlin <jacob.bohlin@arm.com>2020-08-21 11:57:51 +0200
commit1cdc4675bab71c8a8d15b1687790954dab42ddd1 (patch)
tree3de5fd7a8d13f2a48e690d4a16391804b8d1ef48
parent6c87807ad1dc2ac35b05cb1e375544f04e123db1 (diff)
downloadethos-u-vela-1cdc4675bab71c8a8d15b1687790954dab42ddd1.tar.gz
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
-rw-r--r--ethosu/vela/scaling.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/ethosu/vela/scaling.py b/ethosu/vela/scaling.py
index 7019c217..fcf054e0 100644
--- a/ethosu/vela/scaling.py
+++ b/ethosu/vela/scaling.py
@@ -33,7 +33,7 @@ def quantise_scale(scale):
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