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 <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com>
diff --git a/tests/validation/CPP/QuantizationLayer.cpp b/tests/validation/CPP/QuantizationLayer.cpp
index 6909da9..d7ce490 100644
--- a/tests/validation/CPP/QuantizationLayer.cpp
+++ b/tests/validation/CPP/QuantizationLayer.cpp
@@ -23,6 +23,8 @@
*/
#include "QuantizationLayer.h"
+#include <cmath>
+
namespace arm_compute
{
namespace test
@@ -46,21 +48,15 @@
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