From bb3be3989b59de054e2a5d82492290ee6be928b0 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Wed, 20 Sep 2017 18:36:03 +0100 Subject: COMPMID-417: Fix initial min/max value in CPPQuantizationLayer The first element of the first batch was wrongly used as an initial value for min/max of all the batches. Changes initial min/max values so that the first element of the corresponding batch to be used. Change-Id: Icaada0098616e111f5b66f47033fb61cf47a7a39 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/88481 Tested-by: Kaizen Reviewed-by: Moritz Pflanzer --- tests/validation/CPP/QuantizationLayer.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'tests') diff --git a/tests/validation/CPP/QuantizationLayer.cpp b/tests/validation/CPP/QuantizationLayer.cpp index 6909da927e..d7ce490209 100644 --- a/tests/validation/CPP/QuantizationLayer.cpp +++ b/tests/validation/CPP/QuantizationLayer.cpp @@ -23,6 +23,8 @@ */ #include "QuantizationLayer.h" +#include + namespace arm_compute { namespace test @@ -46,21 +48,15 @@ SimpleTensor quantization_layer(const SimpleTensor &src) for(int k = 0; k < num_batches; ++k) { // Compute min and max of the 3D tensor - float min = src[0]; - float max = src[0]; + 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]; - if(val < min) - { - min = val; - } - if(val > max) - { - max = val; - } + min = std::min(min, val); + max = std::max(max, val); } // Saturate the result in case min = max -- cgit v1.2.1