From e03802edd37229a1868bacedd7571cc443810caf Mon Sep 17 00:00:00 2001 From: Usama Arif Date: Mon, 11 Mar 2019 12:20:20 +0000 Subject: COMPMID-1936: Add support for QASYMM8 in CLQuantizeLayer. Change-Id: I9aa1f1f1753bcdee6a74ec15b4fb366f823788b4 Signed-off-by: Usama Arif Reviewed-on: https://review.mlplatform.org/c/850 Reviewed-by: Georgios Pinitas Tested-by: Arm Jenkins --- tests/validation/reference/QuantizationLayer.cpp | 50 +----------------------- tests/validation/reference/QuantizationLayer.h | 3 -- 2 files changed, 1 insertion(+), 52 deletions(-) (limited to 'tests/validation/reference') 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 ::value, int>::type> -SimpleTensor quantization_layer(const SimpleTensor &src) -{ - // Create reference - SimpleTensor 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(std::min(255.0f, normalized * 256.0f)); - } - } - - return dst; -} - -template SimpleTensor quantization_layer(const SimpleTensor &src); - template SimpleTensor quantization_layer(const SimpleTensor &src, const QuantizationInfo quantization_info) { @@ -98,6 +49,7 @@ SimpleTensor quantization_layer(const SimpleTensor &src, const Quant } return dst; } + template SimpleTensor quantization_layer(const SimpleTensor &src, const QuantizationInfo quantization_info); template SimpleTensor quantization_layer(const SimpleTensor &src, const QuantizationInfo quantization_info); } // namespace reference diff --git a/tests/validation/reference/QuantizationLayer.h b/tests/validation/reference/QuantizationLayer.h index 60d8ea4023..2d136908af 100644 --- a/tests/validation/reference/QuantizationLayer.h +++ b/tests/validation/reference/QuantizationLayer.h @@ -35,9 +35,6 @@ namespace validation { namespace reference { -template ::value, int>::type = 0> -SimpleTensor quantization_layer(const SimpleTensor &src); - template SimpleTensor quantization_layer(const SimpleTensor &src, const QuantizationInfo quantization_info); } // namespace reference -- cgit v1.2.1