From 1cdc4675bab71c8a8d15b1687790954dab42ddd1 Mon Sep 17 00:00:00 2001 From: Jacob Bohlin Date: Thu, 20 Aug 2020 15:51:37 +0200 Subject: 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 Change-Id: I4ca368284c097820f83e5ae53412a08c34516c7f --- ethosu/vela/scaling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ethosu/vela') 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 -- cgit v1.2.1