diff options
author | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2021-07-29 16:24:36 +0100 |
---|---|---|
committer | Gian Marco Iodice <gianmarco.iodice@arm.com> | 2021-07-30 14:31:52 +0000 |
commit | 9a1e28b4df4f5b49bb497c8463a8bc7cedaaf110 (patch) | |
tree | 72e151bfae03a83019fb4c4da42ffabf5c7a2826 /src/core | |
parent | a76e40347eed7f9f51ec019e08f4ed16f3621e7b (diff) | |
download | ComputeLibrary-9a1e28b4df4f5b49bb497c8463a8bc7cedaaf110.tar.gz |
Compilation issue: neon=1 armv8.2 on Android with NDKr18beta1
- The issue was related to the __fp16 specialization on the depthwise
convolution layer (cpu)
Resolves COMPMID-4741
Change-Id: I6072230c60df6659951db2a1adf611eca6ab7efe
Signed-off-by: Gian Marco Iodice <gianmarco.iodice@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6026
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Diffstat (limited to 'src/core')
4 files changed, 36 insertions, 30 deletions
diff --git a/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst.hpp b/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst.hpp index a92817bb14..53ad5b5c6b 100644 --- a/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst.hpp +++ b/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst.hpp @@ -154,16 +154,7 @@ class DepthwiseDepthfirst : public DepthwiseCommon<typename strategy::input_type // Compute activation values TAccum activation_min, activation_max; - if (std::numeric_limits<TAccum>::is_integer) - { - activation_min = std::numeric_limits<TAccum>::min(); - activation_max = std::numeric_limits<TAccum>::max(); - } - else - { - activation_min = static_cast<TAccum>(-std::numeric_limits<float>::infinity()); - activation_max = static_cast<TAccum>(std::numeric_limits<float>::infinity()); - } + std::tie(activation_min, activation_max) = get_default_activation_values<TAccum>(); switch (this->m_args.activation.type) { diff --git a/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst_generic.hpp b/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst_generic.hpp index ee5ab84d14..f04f7751db 100644 --- a/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst_generic.hpp +++ b/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst_generic.hpp @@ -333,16 +333,7 @@ class DepthwiseDepthfirstGeneric : public DepthwiseDepthfirstGenericBase<Strateg // Compute activation values TAccum activation_min, activation_max; - if (std::numeric_limits<TAccum>::is_integer) - { - activation_min = std::numeric_limits<TAccum>::min(); - activation_max = std::numeric_limits<TAccum>::max(); - } - else - { - activation_min = static_cast<TAccum>(-std::numeric_limits<float>::infinity()); - activation_max = static_cast<TAccum>(std::numeric_limits<float>::infinity()); - } + std::tie(activation_min, activation_max) = get_default_activation_values<TAccum>(); switch (this->m_args.activation.type) { diff --git a/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst_generic_multiplier.hpp b/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst_generic_multiplier.hpp index 31e5834366..bb580e605a 100644 --- a/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst_generic_multiplier.hpp +++ b/src/core/NEON/kernels/arm_conv/depthwise/depthwise_depthfirst_generic_multiplier.hpp @@ -426,16 +426,7 @@ class DepthwiseDepthfirstGenericWithMultiplier : public DepthwiseDepthfirstGener // Compute activation values TAccum activation_min, activation_max; - if (std::numeric_limits<TAccum>::is_integer) - { - activation_min = std::numeric_limits<TAccum>::min(); - activation_max = std::numeric_limits<TAccum>::max(); - } - else - { - activation_min = static_cast<TAccum>(-std::numeric_limits<float>::infinity()); - activation_max = static_cast<TAccum>(std::numeric_limits<float>::infinity()); - } + std::tie(activation_min, activation_max) = get_default_activation_values<TAccum>(); switch (this->m_args.activation.type) { diff --git a/src/core/NEON/kernels/arm_gemm/utils.hpp b/src/core/NEON/kernels/arm_gemm/utils.hpp index 82464d2eff..2ae3db19ed 100644 --- a/src/core/NEON/kernels/arm_gemm/utils.hpp +++ b/src/core/NEON/kernels/arm_gemm/utils.hpp @@ -27,6 +27,7 @@ #include "arm_gemm.hpp" #include <cstddef> +#include <tuple> // Macro for unreachable code (e.g. impossible default cases on switch) #define UNREACHABLE(why) __builtin_unreachable() @@ -202,6 +203,38 @@ inline unsigned long get_vector_length(VLType vl_type) { return 16 / sizeof(T); } } + +// get_default_activation_values(): Returns the default values for activation min and max for integer activation. +template <typename T> +inline std::tuple<T, T> get_default_activation_values() +{ + const T min = static_cast<T>(std::numeric_limits<T>::min()); + const T max = static_cast<T>(std::numeric_limits<T>::max()); + + return std::make_tuple(min, max); +} + +// get_default_activation_values(): Returns the default values for activation min and max for float activation. +template <> +inline std::tuple<float, float> get_default_activation_values() +{ + const float min = static_cast<float>(-std::numeric_limits<float>::infinity()); + const float max = static_cast<float>(std::numeric_limits<float>::infinity()); + + return std::make_tuple(min, max); +} + +#if defined(__ARM_FP16_ARGS) +// get_default_activation_values(): Returns the default values for activation min and max for __fp16 activation. +template <> +inline std::tuple<__fp16, __fp16> get_default_activation_values() +{ + const __fp16 min = static_cast<__fp16>(-std::numeric_limits<float>::infinity()); + const __fp16 max = static_cast<__fp16>(std::numeric_limits<float>::infinity()); + + return std::make_tuple(min, max); +} +#endif // defined(__ARM_FP16_ARGS) } // utils namespace } // arm_gemm namespace |