diff options
author | Jonathan Deakin <jonathan.deakin@arm.com> | 2022-08-23 11:44:18 +0100 |
---|---|---|
committer | Pablo Marquez Tello <pablo.tello@arm.com> | 2022-09-26 08:28:46 +0000 |
commit | d6b8a71714361881a249a6f6ed67125f290f4a83 (patch) | |
tree | 63fb3c5fba04980816e41a11240511b3a587a5ad /src/cpu/kernels/activation/generic/neon/impl.h | |
parent | ce79ac6297e6eb2407abd24846b8504dee43770f (diff) | |
download | ComputeLibrary-d6b8a71714361881a249a6f6ed67125f290f4a83.tar.gz |
Add FP32 Neon™ swish activation
Change-Id: Id37b59adbc8c4cbe218d1652aeb02a0b4ce42c66
Signed-off-by: Jonathan Deakin <jonathan.deakin@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/8256
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Pablo Marquez Tello <pablo.tello@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/cpu/kernels/activation/generic/neon/impl.h')
-rw-r--r-- | src/cpu/kernels/activation/generic/neon/impl.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cpu/kernels/activation/generic/neon/impl.h b/src/cpu/kernels/activation/generic/neon/impl.h index 4d4aa8d212..4f392866b5 100644 --- a/src/cpu/kernels/activation/generic/neon/impl.h +++ b/src/cpu/kernels/activation/generic/neon/impl.h @@ -149,6 +149,9 @@ void fp_neon_activation_impl(const ITensor *src, ITensor *dst, const ActivationL case ActivationLayerInfo::ActivationFunction::HARD_SWISH: tmp = wrapper::vmul(vin, wrapper::vmul(const_inv_6, wrapper::vmin(const_6, wrapper::vmax(const_0, wrapper::vadd(vin, const_3))))); break; + case ActivationLayerInfo::ActivationFunction::SWISH: + tmp = wrapper::vmul(vin, wrapper::vinv(wrapper::vadd(const_1, wrapper::vexpq(wrapper::vneg(wrapper::vmul(va, vin)))))); + break; #ifdef __aarch64__ case ActivationLayerInfo::ActivationFunction::GELU: tmp = wrapper::vmul(vin, wrapper::vmul(const_inv_2, wrapper::vadd(const_1, wrapper::verf(wrapper::vmul(vin, const_inv_sqrt_2))))); @@ -208,6 +211,9 @@ void fp_neon_activation_impl(const ITensor *src, ITensor *dst, const ActivationL case ActivationLayerInfo::ActivationFunction::HARD_SWISH: tmp = in * ((std::min(std::max((in + 3), 0.0f), 6.0f)) * 0.166666667f); break; + case ActivationLayerInfo::ActivationFunction::SWISH: + tmp = in / (static_cast<T>(1) + std::exp(-a*in)); + break; case ActivationLayerInfo::ActivationFunction::GELU: tmp = in * static_cast<T>(0.5f * (1.0f + erff(static_cast<float>(in) / 1.41421356237f))); break; |