From 4c5469b192665c94118a8a558787cb9cec2d0765 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 21 May 2019 13:32:43 +0100 Subject: COMPMID-2225: Add interface support for new quantized data types. Add support for: -QSYMM8, 8-bit quantized symmetric -QSYMM8_PER_CHANNEL, 8-bit quantized symmetric with per channel quantization Change-Id: I00c4ff98e44af37419470af61419ee95d0de2463 Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/1236 Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice Comments-Addressed: Arm Jenkins --- arm_compute/core/Utils.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'arm_compute/core/Utils.h') diff --git a/arm_compute/core/Utils.h b/arm_compute/core/Utils.h index 1de0df6096..8630eeee23 100644 --- a/arm_compute/core/Utils.h +++ b/arm_compute/core/Utils.h @@ -111,7 +111,9 @@ inline size_t data_size_from_type(DataType data_type) { case DataType::U8: case DataType::S8: + case DataType::QSYMM8: case DataType::QASYMM8: + case DataType::QSYMM8_PER_CHANNEL: return 1; case DataType::U16: case DataType::S16: @@ -183,7 +185,9 @@ inline size_t element_size_from_data_type(DataType dt) { case DataType::S8: case DataType::U8: + case DataType::QSYMM8: case DataType::QASYMM8: + case DataType::QSYMM8_PER_CHANNEL: return 1; case DataType::U16: case DataType::S16: @@ -521,7 +525,9 @@ inline DataType get_promoted_data_type(DataType dt) return DataType::U32; case DataType::S16: return DataType::S32; + case DataType::QSYMM8: case DataType::QASYMM8: + case DataType::QSYMM8_PER_CHANNEL: case DataType::F16: case DataType::U32: case DataType::S32: @@ -999,7 +1005,9 @@ inline bool is_data_type_quantized(DataType dt) { switch(dt) { + case DataType::QSYMM8: case DataType::QASYMM8: + case DataType::QSYMM8_PER_CHANNEL: return true; default: return false; @@ -1059,14 +1067,14 @@ inline size_t num_of_elements_in_range(const float start, const float end, const /** 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 + * @param[in] val value to be checked + * @param[in] dt data type that is checked + * @param[in] qinfo (Optional) 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()) +bool check_value_range(T val, DataType dt, QuantizationInfo qinfo = QuantizationInfo()) { switch(dt) { @@ -1074,8 +1082,8 @@ bool check_value_range(T val, DataType dt, QuantizationInfo quant_info = Quantiz 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())); + double min = static_cast(dequantize_qasymm8(0, qinfo)); + double max = static_cast(dequantize_qasymm8(std::numeric_limits::max(), qinfo)); return ((double)val >= min && (double)val <= max); } case DataType::S8: -- cgit v1.2.1