diff options
author | Usama Arif <usama.arif@arm.com> | 2019-03-11 12:20:20 +0000 |
---|---|---|
committer | Pablo Marquez <pablo.tello@arm.com> | 2019-03-14 10:37:30 +0000 |
commit | e03802edd37229a1868bacedd7571cc443810caf (patch) | |
tree | 018d294c4b55a64bc0fa579f5c011baeb2aaa6a4 /tests/validation/reference/QuantizationLayer.cpp | |
parent | 917959c88361e8148696c156453f69c6ae0c95c0 (diff) | |
download | ComputeLibrary-e03802edd37229a1868bacedd7571cc443810caf.tar.gz |
COMPMID-1936: Add support for QASYMM8 in CLQuantizeLayer.
Change-Id: I9aa1f1f1753bcdee6a74ec15b4fb366f823788b4
Signed-off-by: Usama Arif <usama.arif@arm.com>
Reviewed-on: https://review.mlplatform.org/c/850
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'tests/validation/reference/QuantizationLayer.cpp')
-rw-r--r-- | tests/validation/reference/QuantizationLayer.cpp | 50 |
1 files changed, 1 insertions, 49 deletions
diff --git a/tests/validation/reference/QuantizationLayer.cpp b/tests/validation/reference/QuantizationLayer.cpp index 3d6c5bc13d..2f3348178c 100644 --- a/tests/validation/reference/QuantizationLayer.cpp +++ b/tests/validation/reference/QuantizationLayer.cpp @@ -33,55 +33,6 @@ namespace validation { namespace reference { -template <typename T, typename std::enable_if<is_floating_point<T>::value, int>::type> -SimpleTensor<uint8_t> quantization_layer(const SimpleTensor<T> &src) -{ - // Create reference - SimpleTensor<uint8_t> dst{ src.shape(), DataType::U8 }; - - const int width = src.shape().x(); - const int height = src.shape().y(); - const int depth = src.shape().z(); - const int stride_w = width * height * depth; - const int num_batches = src.shape().total_size_upper(3); - - for(int k = 0; k < num_batches; ++k) - { - // Compute min and max of the 3D tensor - float min = src[k * stride_w]; - float max = src[k * stride_w]; - - // Look for min and max values - for(int i = 1; i < stride_w; ++i) - { - float val = src[i + k * stride_w]; - min = std::min(min, val); - max = std::max(max, val); - } - - // Saturate the result in case min = max - if(min == max) - { - min = 0.0f; - max = 1.0f; - } - - const float range = max - min; - - for(int i = 0; i < stride_w; ++i) - { - // map values to range [0.0, 1.0] - float val = src[i + k * stride_w]; - const float normalized = (val - min) / range; - dst[i + k * stride_w] = static_cast<uint8_t>(std::min(255.0f, normalized * 256.0f)); - } - } - - return dst; -} - -template SimpleTensor<uint8_t> quantization_layer(const SimpleTensor<float> &src); - template <typename T> SimpleTensor<uint8_t> quantization_layer(const SimpleTensor<T> &src, const QuantizationInfo quantization_info) { @@ -98,6 +49,7 @@ SimpleTensor<uint8_t> quantization_layer(const SimpleTensor<T> &src, const Quant } return dst; } + template SimpleTensor<uint8_t> quantization_layer(const SimpleTensor<half> &src, const QuantizationInfo quantization_info); template SimpleTensor<uint8_t> quantization_layer(const SimpleTensor<float> &src, const QuantizationInfo quantization_info); } // namespace reference |