aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormorgolock <pablo.tello@arm.com>2020-05-11 16:00:04 +0100
committerGeorgios Pinitas <georgios.pinitas@arm.com>2020-05-15 11:24:27 +0000
commit3155f77d23eb332974a6b9cb5d37a1329b8493a6 (patch)
treea581a882a677e8d39177c84f1f321c9ff27707ad
parent090502887d87f52d28e98e90c0e17c582b9e63d6 (diff)
downloadComputeLibrary-3155f77d23eb332974a6b9cb5d37a1329b8493a6.tar.gz
COMPMID-3457: vexp failure in QASYMM8_SIGNED overflowing
Change-Id: Ied11a4a3e9d04615a1a1f0bfa552f3dd8293a170 Signed-off-by: morgolock <pablo.tello@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/3178 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--arm_compute/core/NEON/NEMath.h1
-rw-r--r--arm_compute/core/NEON/NEMath.inl6
2 files changed, 6 insertions, 1 deletions
diff --git a/arm_compute/core/NEON/NEMath.h b/arm_compute/core/NEON/NEMath.h
index 3905f67e29..8827bbf459 100644
--- a/arm_compute/core/NEON/NEMath.h
+++ b/arm_compute/core/NEON/NEMath.h
@@ -25,6 +25,7 @@
#define ARM_COMPUTE_NEMATH_H
#include <arm_neon.h>
+#include <array>
namespace arm_compute
{
diff --git a/arm_compute/core/NEON/NEMath.inl b/arm_compute/core/NEON/NEMath.inl
index 49870d06a8..032bfde238 100644
--- a/arm_compute/core/NEON/NEMath.inl
+++ b/arm_compute/core/NEON/NEMath.inl
@@ -22,6 +22,7 @@
* SOFTWARE.
*/
#include <cmath>
+#include <limits>
#ifndef M_PI
#define M_PI (3.14159265358979323846)
@@ -147,6 +148,8 @@ inline float32x4_t vexpq_f32(float32x4_t x)
{
static const float32x4_t CONST_LN2 = vdupq_n_f32(0.6931471805f); // ln(2)
static const float32x4_t CONST_INV_LN2 = vdupq_n_f32(1.4426950408f); // 1/ln(2)
+ static const float32x4_t CONST_INF = vdupq_n_f32(std::numeric_limits<float>::infinity());
+ static const float32x4_t CONST_MAX_INPUT = vdupq_n_f32(88.7f);
static const float32x4_t CONST_0 = vdupq_n_f32(0.f);
static const int32x4_t CONST_NEGATIVE_126 = vdupq_n_s32(-126);
@@ -159,7 +162,8 @@ inline float32x4_t vexpq_f32(float32x4_t x)
// Reconstruct
poly = vreinterpretq_f32_s32(vqaddq_s32(vreinterpretq_s32_f32(poly), vqshlq_n_s32(m, 23)));
- poly = vbslq_f32(vcltq_s32(m, CONST_NEGATIVE_126), CONST_0, poly);
+ poly = vbslq_f32(vcltq_s32(m, CONST_NEGATIVE_126), CONST_0, poly); // Handle underflow
+ poly = vbslq_f32(vcgtq_f32(x, CONST_MAX_INPUT), CONST_INF, poly); // Handle overflow
return poly;
}