diff options
author | Eric Kunze <eric.kunze@arm.com> | 2022-11-11 15:21:56 -0800 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2022-11-18 23:23:11 +0000 |
commit | 52460a8b21e3691cd56b22e62986fa24012b8e68 (patch) | |
tree | 853c0a8065b1ae357b3dcca28d40059f5e1c4018 | |
parent | 41a04feacf0fecc14b1d0c50c39a1dc3e3710c4d (diff) | |
download | reference_model-52460a8b21e3691cd56b22e62986fa24012b8e68.tar.gz |
Zero point addition in RESCALE should be int32
Clipping to the output range is done post zero point addition.
Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Change-Id: I5271a08fb2f6f9804fb1af3c6945131f948f452a
-rw-r--r-- | reference_model/src/ops/type_conversion.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/reference_model/src/ops/type_conversion.cc b/reference_model/src/ops/type_conversion.cc index e30c7bd..cb57340 100644 --- a/reference_model/src/ops/type_conversion.cc +++ b/reference_model/src/ops/type_conversion.cc @@ -159,7 +159,8 @@ int OpRescale<Rank, InDtype, OutDtype>::eval() else scaled = TosaReference::QuantUtil::apply_scale_16(input_zp_shifted, channel_multiplier, channel_shift); - OutEigenType out_val = (OutEigenType)(scaled + output_zp); + scaled = scaled + output_zp; + OutEigenType out_val = static_cast<OutEigenType>(scaled); out_val = std::max<OutEigenType>(out_val, QMin); out_val = std::min<OutEigenType>(out_val, QMax); return out_val; @@ -192,7 +193,8 @@ int OpRescale<Rank, InDtype, OutDtype>::eval() else scaled = TosaReference::QuantUtil::apply_scale_16(input_zp_shifted, tensor_multiplier, tensor_shift); - OutEigenType out_val = (OutEigenType)(scaled + output_zp); + scaled = scaled + output_zp; + OutEigenType out_val = static_cast<OutEigenType>(scaled); out_val = std::max<OutEigenType>(out_val, QMin); out_val = std::min<OutEigenType>(out_val, QMax); return out_val; |