aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunes Bayir <gunes.bayir@arm.com>2022-11-02 11:50:37 +0000
committerGunes Bayir <gunes.bayir@arm.com>2022-11-02 15:52:27 +0000
commit01934e9953bdc0f3b931e6719241a5e415a4f2a1 (patch)
tree5c60ded128f996e48e4fe764bed9cf2b45674cc6
parent0ae31d1761b61ce0952b032816de2929e606d3c1 (diff)
downloadComputeLibrary-01934e9953bdc0f3b931e6719241a5e415a4f2a1.tar.gz
Partially Revert "Add threshold for floating-point SOFT_RELU activation"
Revert the range removal in tests for soft relu and bring the former implementation in CL backend back. Resolves: COMPMID-5677 Change-Id: I35d5ac03a134299041ce97aabc9fff2d4380d09f Signed-off-by: Gunes Bayir <gunes.bayir@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8551 Reviewed-by: Milos Puzovic <milos.puzovic@arm.com> Reviewed-by: Viet-Hoa Do <viet-hoa.do@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--src/core/CL/cl_kernels/activation_float_helpers.h2
-rw-r--r--tests/validation/Helpers.h4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/core/CL/cl_kernels/activation_float_helpers.h b/src/core/CL/cl_kernels/activation_float_helpers.h
index fe124bc032..3f93c8d6fc 100644
--- a/src/core/CL/cl_kernels/activation_float_helpers.h
+++ b/src/core/CL/cl_kernels/activation_float_helpers.h
@@ -52,7 +52,7 @@
#define lrelu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) ((min(x, (DATA_TYPE)0.0) * (DATA_TYPE)A_VAL) + max(x, (DATA_TYPE)0.0))
// Soft RELU Activation
-#define srelu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (select((log((DATA_TYPE)1.0 + exp(x))), x, (SELECT_VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE))isgreaterequal(x,(DATA_TYPE)16.63553047)))
+#define srelu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (log((DATA_TYPE)1.0 + exp(x)))
// ELU Activation
#define elu_op(DATA_TYPE, VEC_SIZE, x, A_VAL, B_VAL) (select(((DATA_TYPE)A_VAL * (exp(x) - (DATA_TYPE)1.0)), x, (SELECT_VEC_DATA_TYPE(DATA_TYPE, VEC_SIZE))isgreaterequal(x, (DATA_TYPE)0.0)))
diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h
index cbbdfbb6c4..2e48a6b8c6 100644
--- a/tests/validation/Helpers.h
+++ b/tests/validation/Helpers.h
@@ -91,6 +91,10 @@ std::pair<T, T> get_activation_layer_test_bounds(ActivationLayerInfo::Activation
case DataType::F32:
switch(activation)
{
+ case ActivationLayerInfo::ActivationFunction::SOFT_RELU:
+ // Reduce range as exponent overflows
+ bounds = std::make_pair(-40.f, 40.f);
+ break;
case ActivationLayerInfo::ActivationFunction::SQRT:
// Reduce range as sqrt should take a non-negative number
bounds = std::make_pair(0.f, 255.f);