From f63885bc445af1329e6a5c44d94b5c5d78146b2c Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Wed, 16 Jan 2019 14:18:09 +0000 Subject: COMPMID-1710 Move some Util functions to core/Utils Building with exceptions=0 was failing Change-Id: I6f264dc859dedc66d12d522652134508e18d5740 Reviewed-on: https://review.mlplatform.org/526 Reviewed-by: Isabella Gottardi Tested-by: Arm Jenkins --- utils/Utils.h | 63 ----------------------------------------------------------- 1 file changed, 63 deletions(-) (limited to 'utils') diff --git a/utils/Utils.h b/utils/Utils.h index ad71776803..04ccc3e812 100644 --- a/utils/Utils.h +++ b/utils/Utils.h @@ -194,69 +194,6 @@ inline std::string get_typestring(DataType data_type) } } -/** Returns the number of elements required to go from start to end with the wanted step - * - * @param[in] start start value - * @param[in] end end value - * @param[in] step step value between each number in the wanted sequence - * - * @return number of elements to go from start value to end value using the wanted step - */ -inline size_t num_of_elements_in_range(const float start, const float end, const float step) -{ - ARM_COMPUTE_ERROR_ON_MSG(step == 0, "Range Step cannot be 0"); - return size_t(std::ceil((end - start) / step)); -} - -/** Returns true if the value can be represented by the given data type - * - * @param[in] val value to be checked - * @param[in] dt data type that is checked - * @param[in] quant_info quantization info if the data type is QASYMM8 - * - * @return true if the data type can hold the value. - */ -template -bool check_value_range(T val, DataType dt, QuantizationInfo quant_info = QuantizationInfo()) -{ - switch(dt) - { - case DataType::U8: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); - case DataType::QASYMM8: - { - double min = static_cast(quant_info.dequantize(0)); - double max = static_cast(quant_info.dequantize(std::numeric_limits::max())); - 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()); - case DataType::U16: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); - case DataType::S16: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= std::numeric_limits::max()); - case DataType::U32: - return ((static_cast(val) == val) && val >= std::numeric_limits::lowest() && val <= 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()); - 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; - } -} - /** Maps a tensor if needed * * @param[in] tensor Tensor to be mapped -- cgit v1.2.1