From 7ba240bb54bdbd50f1809f944dde2fac7005cc10 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Mon, 20 Apr 2020 17:39:33 +0100 Subject: COMPMID-3069: Fix QASYMM8_SIGNED RELUs in NEActivationLayerKernel Wrong boundaries were used for clamping the output when data type was QASYMM8_SIGNED. Change-Id: Ie93bf64643fce95be2b4a5a63ef2d1dc83bbdd97 Signed-off-by: Michele Di Giorgio Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3064 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas Comments-Addressed: Arm Jenkins --- src/core/NEON/kernels/NEActivationLayerKernel.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/NEON/kernels/NEActivationLayerKernel.cpp b/src/core/NEON/kernels/NEActivationLayerKernel.cpp index 5251209463..a1652447f4 100644 --- a/src/core/NEON/kernels/NEActivationLayerKernel.cpp +++ b/src/core/NEON/kernels/NEActivationLayerKernel.cpp @@ -533,17 +533,17 @@ typename std::enable_if::value, void>::type NEActivat if(act == ActivationFunction::RELU) { tmp = std::max(const_0, in); - tmp = std::max(0, std::min(tmp * s + o, 255)); + tmp = utility::clamp(tmp * s + o); } else if(act == ActivationFunction::BOUNDED_RELU) { tmp = std::min(a, std::max(const_0, in)); - tmp = std::max(0, std::min(tmp * s + o, 255)); + tmp = utility::clamp(tmp * s + o); } else if(act == ActivationFunction::LU_BOUNDED_RELU) { tmp = std::min(a, std::max(b, in)); - tmp = std::max(0, std::min(tmp * s + o, 255)); + tmp = utility::clamp(tmp * s + o); } else if(act == ActivationFunction::LOGISTIC) { @@ -710,17 +710,17 @@ typename std::enable_if::value, void>::type NE if(act == ActivationFunction::RELU) { tmp = std::max(const_0, in); - tmp = std::max(0, std::min(tmp * s + o, 255)); + tmp = utility::clamp(tmp * s + o); } else if(act == ActivationFunction::BOUNDED_RELU) { tmp = std::min(a, std::max(const_0, in)); - tmp = std::max(0, std::min(tmp * s + o, 255)); + tmp = utility::clamp(tmp * s + o); } else if(act == ActivationFunction::LU_BOUNDED_RELU) { tmp = std::min(a, std::max(b, in)); - tmp = std::max(0, std::min(tmp * s + o, 255)); + tmp = utility::clamp(tmp * s + o); } else if(act == ActivationFunction::LOGISTIC) { -- cgit v1.2.1