From a32e2aef81cfcba9f5ae1770ceeb4a8d26fdc1f4 Mon Sep 17 00:00:00 2001 From: SiCong Li Date: Mon, 8 Jun 2020 17:30:51 +0100 Subject: COMPMID-3523: Fix validation fails on armv8.2-a * Fix neon sqrt activation delta(epsilon) * Fix NEON Hard Swish validation tolerance * Fix NEON FP16 LogSoftmaxLayer validation test typo * Raise NEON reduction (sum) f16 tolerance Change-Id: Ia33d69ce5f0b78be1893fb8e13d2761a8e7fceff Signed-off-by: SiCong Li Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3318 Comments-Addressed: Arm Jenkins Reviewed-by: Michele Di Giorgio Tested-by: Arm Jenkins --- src/core/NEON/kernels/NEActivationLayerKernel.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/core/NEON/kernels/NEActivationLayerKernel.cpp') diff --git a/src/core/NEON/kernels/NEActivationLayerKernel.cpp b/src/core/NEON/kernels/NEActivationLayerKernel.cpp index 8e91e6b4d1..ffbfd710f9 100644 --- a/src/core/NEON/kernels/NEActivationLayerKernel.cpp +++ b/src/core/NEON/kernels/NEActivationLayerKernel.cpp @@ -265,7 +265,12 @@ NEActivationLayerKernel::activation(const Window &window) Iterator input(_input, win_collapsed); Iterator output(_output, win_collapsed); - const auto epsilon = wrapper::vdup_n(static_cast(1e-24), ExactTagType{}); + // A small delta added to the input to prevent NAN values caused by zeros in inputs to SQRT +#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC + const auto delta = wrapper::vdup_n(static_cast(1e-7), ExactTagType{}); +#else /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ + const auto delta = wrapper::vdup_n(static_cast(1e-24), ExactTagType{}); +#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */ const auto const_1 = wrapper::vdup_n(static_cast(1.f), ExactTagType{}); const auto const_0 = wrapper::vdup_n(static_cast(0.f), ExactTagType{}); const auto const_6 = wrapper::vdup_n(static_cast(6.f), ExactTagType{}); @@ -318,7 +323,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 + epsilon)); + tmp = wrapper::vinv(wrapper::vinvsqrt(wrapper::vadd(vin, delta))); break; case ActivationFunction::SQUARE: tmp = wrapper::vmul(vin, vin); -- cgit v1.2.1