diff options
author | Jeremy Johnson <jeremy.johnson@arm.com> | 2024-04-30 13:56:20 +0100 |
---|---|---|
committer | Jeremy Johnson <jeremy.johnson@arm.com> | 2024-05-01 11:08:27 +0100 |
commit | 29b02017bf9e0ac381da068e1819632a56cf9966 (patch) | |
tree | 3aff90b874a84bf89819078d28b746c16607a349 /reference_model | |
parent | 8ded90d7894528f4bb0418213db08e947d3a6def (diff) | |
download | reference_model-29b02017bf9e0ac381da068e1819632a56cf9966.tar.gz |
Fix MAXIMUM/MINIMUM handling of NaNs and zeroes
Change FP_SPECIAL testing to be used for DOT_PRODUCT cases only.
Use default EXACT matching - where zeroes of different signs will
be ignored when testing for equality
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
Change-Id: I0461c42258611cae597f693507075b3ef15fbe19
Diffstat (limited to 'reference_model')
-rw-r--r-- | reference_model/src/ops/ewise_binary.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/reference_model/src/ops/ewise_binary.cc b/reference_model/src/ops/ewise_binary.cc index 8cc1319..d4a9f2f 100644 --- a/reference_model/src/ops/ewise_binary.cc +++ b/reference_model/src/ops/ewise_binary.cc @@ -411,6 +411,22 @@ int OpMaximum<Rank, Dtype>::register_fcn() case TOSA_REF_TYPE_BF16: case TOSA_REF_TYPE_FP32: case TOSA_REF_TYPE_FP64: + this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { + if (isnan(a)) + { + return a; + } + else if (isnan(b)) + { + return b; + } + else + { + return a > b ? a : b; + } + }; + break; + case TOSA_REF_TYPE_INT32: this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a > b ? a : b; }; break; @@ -430,6 +446,21 @@ int OpMinimum<Rank, Dtype>::register_fcn() case TOSA_REF_TYPE_BF16: case TOSA_REF_TYPE_FP32: case TOSA_REF_TYPE_FP64: + this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { + if (isnan(a)) + { + return a; + } + else if (isnan(b)) + { + return b; + } + else + { + return a < b ? a : b; + } + }; + break; case TOSA_REF_TYPE_INT32: this->fcn = [](InEigenType a, InEigenType b) -> OutEigenType { return a < b ? a : b; }; break; |