aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Di Giorgio <michele.digiorgio@arm.com>2019-09-13 12:23:46 +0100
committerMichele Di Giorgio <michele.digiorgio@arm.com>2019-09-13 13:49:13 +0000
commit8d5dd867c32fc31f635fdc58783c29a38a99ebb7 (patch)
tree01924058c48657e4f83e8663b5dd145bed027970
parentc370c754ebd133cfed19ad1773ef540e48bd4240 (diff)
downloadComputeLibrary-8d5dd867c32fc31f635fdc58783c29a38a99ebb7.tar.gz
COMPMID-2659: Activation.SQRT Failure on NEON
When one of the inputs is zero in a NEON vector our computation of square root returns -nan. This patch adds a small epsilon to the input to avoid this issue. Change-Id: I0357001fd2ff0f868acfaae66b47b6962dbb0144 Signed-off-by: Michele Di Giorgio <michele.digiorgio@arm.com> Reviewed-on: https://review.mlplatform.org/c/1921 Reviewed-by: Pablo Marquez <pablo.tello@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--src/core/NEON/kernels/NEActivationLayerKernel.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/core/NEON/kernels/NEActivationLayerKernel.cpp b/src/core/NEON/kernels/NEActivationLayerKernel.cpp
index 242382c206..6f722e0457 100644
--- a/src/core/NEON/kernels/NEActivationLayerKernel.cpp
+++ b/src/core/NEON/kernels/NEActivationLayerKernel.cpp
@@ -228,6 +228,7 @@ NEActivationLayerKernel::activation(const Window &window)
Iterator input(_input, win_collapsed);
Iterator output(_output, win_collapsed);
+ const auto epsilon = wrapper::vdup_n(static_cast<T>(1e-24), ExactTagType{});
const auto const_1 = wrapper::vdup_n(static_cast<T>(1.f), ExactTagType{});
const auto const_0 = wrapper::vdup_n(static_cast<T>(0.f), ExactTagType{});
const auto va = wrapper::vdup_n(static_cast<T>(_act_info.a()), ExactTagType{});
@@ -277,7 +278,7 @@ NEActivationLayerKernel::activation(const Window &window)
tmp = wrapper::vbsl(wrapper::vcge(vin, const_0), vin, wrapper::vmul(va, wrapper::vsub(wrapper::vexpq(vin), const_1)));
break;
case ActivationFunction::SQRT:
- tmp = wrapper::vinv(wrapper::vinvsqrt(vin));
+ tmp = wrapper::vinv(wrapper::vinvsqrt(vin + epsilon));
break;
case ActivationFunction::SQUARE:
tmp = wrapper::vmul(vin, vin);