aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/Utils.h
diff options
context:
space:
mode:
authorMohammed Suhail Munshi <MohammedSuhail.Munshi@arm.com>2022-02-08 15:23:00 +0000
committerMohmun02 <MohammedSuhail.Munshi@arm.com>2022-02-10 15:30:29 +0000
commit2134d1bdb81e4959560d5becea06c43c083a9811 (patch)
treebfb1cc161ccea50a2e35b3e504a223c9e16beb27 /arm_compute/core/Utils.h
parent616f8eb38e6b68001b162a88ad404d04f7b32fd2 (diff)
downloadComputeLibrary-2134d1bdb81e4959560d5becea06c43c083a9811.tar.gz
Int32 to Float32 implicit casting fix
- Int32 is cast to Float32 implicitly during range checking comparisons, value may change due to float32 range limitations. - Fixed by casting float32 var to double64 before comparisons. - This issue prevented NDK r23b compilation Resolves: [COMPMID-5051] Change-Id: I1695f9ad5fa147d81cbcfda9e0152aefab960c82 Signed-off-by: Mohammed Suhail Munshi <MohammedSuhail.Munshi@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7093 Tested-by: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Sheri Zhang <sheri.zhang@arm.com>
Diffstat (limited to 'arm_compute/core/Utils.h')
-rw-r--r--arm_compute/core/Utils.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/arm_compute/core/Utils.h b/arm_compute/core/Utils.h
index b24955d778..a279ef310a 100644
--- a/arm_compute/core/Utils.h
+++ b/arm_compute/core/Utils.h
@@ -1156,13 +1156,15 @@ bool check_value_range(T val, DataType dt, QuantizationInfo qinfo = Quantization
}
case DataType::U32:
{
+ const auto val_d64 = static_cast<double>(val);
const auto val_u32 = static_cast<uint32_t>(val);
- return ((val_u32 == val) && val >= std::numeric_limits<uint32_t>::lowest() && val <= std::numeric_limits<uint32_t>::max());
+ return ((val_u32 == val_d64) && val_d64 >= std::numeric_limits<uint32_t>::lowest() && val_d64 <= std::numeric_limits<uint32_t>::max());
}
case DataType::S32:
{
+ const auto val_d64 = static_cast<double>(val);
const auto val_s32 = static_cast<int32_t>(val);
- return ((val_s32 == val) && val >= std::numeric_limits<int32_t>::lowest() && val <= std::numeric_limits<int32_t>::max());
+ return ((val_s32 == val_d64) && val_d64 >= std::numeric_limits<int32_t>::lowest() && val_d64 <= std::numeric_limits<int32_t>::max());
}
case DataType::BFLOAT16:
return (val >= bfloat16::lowest() && val <= bfloat16::max());