aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/weight_compressor.py
diff options
context:
space:
mode:
authorTim Hall <tim.hall@arm.com>2023-05-16 22:39:14 +0100
committertim.hall <tim.hall@arm.com>2023-05-17 11:05:57 +0000
commit5ff4cd12898f44228288a7969b52dff97be30cb2 (patch)
tree1c8068c02254d5479706e41379bbd1f8c7b33205 /ethosu/vela/weight_compressor.py
parent0426fe9de82e0f6b339edbd2bec78a5d322fb05f (diff)
downloadethos-u-vela-5ff4cd12898f44228288a7969b52dff97be30cb2.tar.gz
MLBEDSW-7223: Fusing Pad and AvgPool causes diff
- Fixed an issue with the fusing of PAD and AVERAGE_POOL_2D whereby the rounding away from zero didn't work because it requires the zero point to be at zero but the input padding required it to be set to the desired zero point. This affected both int8 and int16. The solution was to remove it by using the bias prior to the scaling - Refactored the rounding away from zero mode Change-Id: I8f2df69df06d2a9722315c346646e5a901cb2c3b Signed-off-by: Tim Hall <tim.hall@arm.com>
Diffstat (limited to 'ethosu/vela/weight_compressor.py')
-rw-r--r--ethosu/vela/weight_compressor.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/ethosu/vela/weight_compressor.py b/ethosu/vela/weight_compressor.py
index e4779bf5..50ae26c0 100644
--- a/ethosu/vela/weight_compressor.py
+++ b/ethosu/vela/weight_compressor.py
@@ -32,6 +32,7 @@ from .errors import UnsupportedFeatureError
from .numeric_util import round_up
from .operation import NpuBlockType
from .operation import Op
+from .operation import RoundingMode
from .scaling import quantise_scale
from .scaling import reduced_quantise_scale
from .tensor import QuantizationParameters
@@ -303,8 +304,8 @@ def _prepare_scale_and_bias(arch, tens, explicit_scaling):
else:
quantised_scales = [quantise_scale(scale) for scale in scales]
- # Check the output quantisation to see if the scale value needs increasing to the next one
- if _get_output_quantization(first_consumer_op).next_after:
+ # Rounding away from zero requires the "next after" floating point value to be set on the output quantisation
+ if first_consumer_op.rounding_mode == RoundingMode.AwayZero:
for i, quant_scale in enumerate(quantised_scales):
q_scale, q_shift = quant_scale
quantised_scales[i] = (q_scale + 1, q_shift)