aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/scaling.py
diff options
context:
space:
mode:
Diffstat (limited to 'ethosu/vela/scaling.py')
-rw-r--r--ethosu/vela/scaling.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/ethosu/vela/scaling.py b/ethosu/vela/scaling.py
index fcf054e0..74f21660 100644
--- a/ethosu/vela/scaling.py
+++ b/ethosu/vela/scaling.py
@@ -46,6 +46,10 @@ def reduced_quantise_scale(scale):
reduced_multiplier = int((multiplier + (1 << 15)) >> 16)
reduced_shift = shift - 16
+ if not (0 <= shift < (1 << 6)):
+ # Shift outside of valid range, set scale to 0
+ return 0, 16
+
return reduced_multiplier, reduced_shift