diff options
author | Eric Kunze <eric.kunze@arm.com> | 2024-01-10 00:58:11 +0000 |
---|---|---|
committer | Eric Kunze <eric.kunze@arm.com> | 2024-01-11 00:27:56 +0000 |
commit | 48ed6cf8eb0d6beab4cb97f08fc41e037bfd182e (patch) | |
tree | 6bd951b833b47fe7a4c82a9e4db53521149084db /reference_model/src/ops | |
parent | 89ff71dbab705cd64a7c84892ad5569ab1e18a9a (diff) | |
download | reference_model-48ed6cf8eb0d6beab4cb97f08fc41e037bfd182e.tar.gz |
CLAMP limits should be expressed in in_out_t
int8/int16 should be used for the clamping, not int32_t
Signed-off-by: Eric Kunze <eric.kunze@arm.com>
Change-Id: I18209ca76cc83d95dc61f20f88344aafdbd72033
Diffstat (limited to 'reference_model/src/ops')
-rw-r--r-- | reference_model/src/ops/activation_funcs.cc | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/reference_model/src/ops/activation_funcs.cc b/reference_model/src/ops/activation_funcs.cc index c8fdc74..1f4c3b3 100644 --- a/reference_model/src/ops/activation_funcs.cc +++ b/reference_model/src/ops/activation_funcs.cc @@ -52,12 +52,19 @@ int OpClamp<Rank, Dtype>::register_fcn() this->fcn = [min, max](InEigenType a) -> OutEigenType { return (a <= min ? min : a >= max ? max : a); }; } break; - case TOSA_REF_TYPE_INT8: + case TOSA_REF_TYPE_INT8: { + int8_t min = (int8_t)attribute->min_int(); + int8_t max = (int8_t)attribute->max_int(); + + ERROR_IF(max < min, "OpClamp: max smaller than min"); + this->fcn = [min, max](int8_t a) -> int8_t { return a <= min ? min : a >= max ? max : a; }; + } case TOSA_REF_TYPE_INT16: { - InEigenType min = (InEigenType)attribute->min_int(); - InEigenType max = (InEigenType)attribute->max_int(); + int16_t min = (int16_t)attribute->min_int(); + int16_t max = (int16_t)attribute->max_int(); + ERROR_IF(max < min, "OpClamp: max smaller than min"); - this->fcn = [min, max](InEigenType a) -> OutEigenType { return a <= min ? min : a >= max ? max : a; }; + this->fcn = [min, max](int16_t a) -> int16_t { return a <= min ? min : a >= max ? max : a; }; } break; default: |