From e874ef9b845424dceeac4211ca9dfec24949f03c Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 9 Sep 2019 17:40:33 +0100 Subject: COMPMID-2646: Wrap thread-related structure to ease bare-metal support Wraps "lock_guard" and "unique_lock" to ease bare-metal support. Adds basic armclang compilation flow. Change-Id: I44ccd042652acd6a9b442c57c879db3891abb0e2 Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/1923 Tested-by: Arm Jenkins Reviewed-by: Pablo Marquez Comments-Addressed: Arm Jenkins --- arm_compute/core/Utils.h | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'arm_compute/core/Utils.h') diff --git a/arm_compute/core/Utils.h b/arm_compute/core/Utils.h index 0ce2ee0161..3f04ed9963 100644 --- a/arm_compute/core/Utils.h +++ b/arm_compute/core/Utils.h @@ -1128,7 +1128,10 @@ bool check_value_range(T val, DataType dt, QuantizationInfo qinfo = Quantization switch(dt) { case DataType::U8: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); + { + const auto val_u8 = static_cast(val); + return ((val_u8 == val) && val_u8 >= std::numeric_limits::lowest() && val_u8 <= std::numeric_limits::max()); + } case DataType::QASYMM8: { double min = static_cast(dequantize_qasymm8(0, qinfo)); @@ -1136,27 +1139,34 @@ bool check_value_range(T val, DataType dt, QuantizationInfo qinfo = Quantization return ((double)val >= min && (double)val <= max); } case DataType::S8: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); + { + const auto val_s8 = static_cast(val); + return ((val_s8 == val) && val_s8 >= std::numeric_limits::lowest() && val_s8 <= std::numeric_limits::max()); + } case DataType::U16: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); + { + const auto val_u16 = static_cast(val); + return ((val_u16 == val) && val_u16 >= std::numeric_limits::lowest() && val_u16 <= std::numeric_limits::max()); + } case DataType::S16: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); + { + const auto val_s16 = static_cast(val); + return ((val_s16 == val) && val_s16 >= std::numeric_limits::lowest() && val_s16 <= std::numeric_limits::max()); + } case DataType::U32: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); + { + const auto val_u32 = static_cast(val); + return ((val_u32 == val) && val_u32 >= std::numeric_limits::lowest() && val_u32 <= std::numeric_limits::max()); + } case DataType::S32: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); - case DataType::U64: - return (val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); - case DataType::S64: - return (val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); + { + const auto val_s32 = static_cast(val); + return ((val_s32 == val) && val_s32 >= std::numeric_limits::lowest() && val_s32 <= std::numeric_limits::max()); + } case DataType::F16: return (val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); case DataType::F32: return (val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); - case DataType::F64: - return (val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); - case DataType::SIZET: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); default: ARM_COMPUTE_ERROR("Data type not supported"); return false; -- cgit v1.2.1