diff options
Diffstat (limited to 'src/core/NEON/kernels/arm_conv/pooling/pooling_fp16.cpp')
-rw-r--r-- | src/core/NEON/kernels/arm_conv/pooling/pooling_fp16.cpp | 126 |
1 files changed, 95 insertions, 31 deletions
diff --git a/src/core/NEON/kernels/arm_conv/pooling/pooling_fp16.cpp b/src/core/NEON/kernels/arm_conv/pooling/pooling_fp16.cpp index 094c6aa301..a7f3dd3a93 100644 --- a/src/core/NEON/kernels/arm_conv/pooling/pooling_fp16.cpp +++ b/src/core/NEON/kernels/arm_conv/pooling/pooling_fp16.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Arm Limited. + * Copyright (c) 2021-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -33,12 +33,18 @@ #include "kernels/cpp_nhwc_1x1_stride_any_depthfirst.hpp" #if defined(__aarch64__) -#if defined(__ARM_FEATURE_SVE) +#if defined(ARM_COMPUTE_ENABLE_SME) +#include "kernels/sme_fp16_nhwc_max_2x2_s1_output2x2_depthfirst.hpp" +#include "kernels/sme_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst.hpp" +#include "kernels/sme_fp16_nhwc_avg_generic_depthfirst.hpp" +#include "kernels/sme_fp16_nhwc_max_generic_depthfirst.hpp" +#endif // defined(ARM_COMPUTE_ENABLE_SME) +#if defined(ARM_COMPUTE_ENABLE_SVE) #include "kernels/sve_fp16_nhwc_max_2x2_s1_output2x2_depthfirst.hpp" #include "kernels/sve_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst.hpp" #include "kernels/sve_fp16_nhwc_avg_generic_depthfirst.hpp" #include "kernels/sve_fp16_nhwc_max_generic_depthfirst.hpp" -#endif // defined(__ARM_FEATURE_SVE) +#endif // defined(ARM_COMPUTE_ENABLE_SVE) #include "kernels/a64_fp16_nhwc_max_2x2_s1_output2x2_depthfirst.hpp" #include "kernels/a64_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst.hpp" #include "kernels/a64_fp16_nhwc_avg_generic_depthfirst.hpp" @@ -48,19 +54,6 @@ namespace arm_conv { namespace pooling { -namespace -{ - template <class Strategy> - bool is_supported(const PoolingArgs &args, const Nothing &) - { - return ((args.pool_type == Strategy::pooling_type()) && - (args.pool_window.rows == Strategy::pool_rows()) && - (args.pool_window.cols == Strategy::pool_cols()) && - (args.pool_stride.rows == Strategy::stride_rows()) && - (args.pool_stride.cols == Strategy::stride_cols())); - } -} - static const PoolingImplementation<__fp16, __fp16> pooling_fp16_methods[] = { { PoolingMethod::DEPTHFIRST, @@ -70,48 +63,115 @@ static const PoolingImplementation<__fp16, __fp16> pooling_fp16_methods[] = { }, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirstGeneric<cpp_nhwc_1x1_stride_any_depthfirst<__fp16>>(args); + auto strat = new cpp_nhwc_1x1_stride_any_depthfirst<__fp16>(args.cpu_info); + return new PoolingDepthfirstGeneric<__fp16>(strat, args); }, }, #if defined(__aarch64__) -#if defined(__ARM_FEATURE_SVE) +#if defined(ARM_COMPUTE_ENABLE_SME) + { + PoolingMethod::DEPTHFIRST, + "sme_fp16_nhwc_max_2x2_s1_output2x2_depthfirst", + [] (const PoolingArgs &args, const Nothing &os) -> bool { + return args.cpu_info->has_sme() && + is_supported<sme_fp16_nhwc_max_2x2_s1_output2x2_depthfirst>(args, os); + }, + nullptr, + [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { + auto strat = new sme_fp16_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info); + return new PoolingDepthfirst<__fp16>(strat, args); + }, + }, + { + PoolingMethod::DEPTHFIRST, + "sme_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst", + [] (const PoolingArgs &args, const Nothing &os) -> bool { + return args.cpu_info->has_sme() && + is_supported<sme_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst>(args, os); + }, + nullptr, + [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { + auto strat = new sme_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst(args.cpu_info); + return new PoolingDepthfirst<__fp16>(strat, args); + }, + }, + { + PoolingMethod::DEPTHFIRST, + "sme_fp16_nhwc_avg_generic_depthfirst", + [] (const PoolingArgs &args, const Nothing &) -> bool { + return args.cpu_info->has_sme() && args.pool_type == PoolingType::AVERAGE; + }, + nullptr, + [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { + auto strat = new sme_fp16_nhwc_avg_generic_depthfirst(args.cpu_info); + return new PoolingDepthfirstGeneric<__fp16>(strat, args); + }, + }, + { + PoolingMethod::DEPTHFIRST, + "sme_fp16_nhwc_max_generic_depthfirst", + [] (const PoolingArgs &args, const Nothing &) -> bool { + return args.cpu_info->has_sme() && args.pool_type == PoolingType::MAX; + }, + nullptr, + [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { + auto strat = new sme_fp16_nhwc_max_generic_depthfirst(args.cpu_info); + return new PoolingDepthfirstGeneric<__fp16>(strat, args); + }, + }, +#endif // defined(ARM_COMPUTE_ENABLE_SME) +#if defined(ARM_COMPUTE_ENABLE_SVE) { PoolingMethod::DEPTHFIRST, "sve_fp16_nhwc_max_2x2_s1_output2x2_depthfirst", - is_supported<sve_fp16_nhwc_max_2x2_s1_output2x2_depthfirst>, + [] (const PoolingArgs &args, const Nothing &os) -> bool { + return args.cpu_info->has_sve() && + is_supported<sve_fp16_nhwc_max_2x2_s1_output2x2_depthfirst>(args, os); + }, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirst<sve_fp16_nhwc_max_2x2_s1_output2x2_depthfirst>(args); + auto strat = new sve_fp16_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info); + return new PoolingDepthfirst<__fp16>(strat, args); }, }, { PoolingMethod::DEPTHFIRST, "sve_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst", - is_supported<sve_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst>, + [] (const PoolingArgs &args, const Nothing &os) -> bool { + return args.cpu_info->has_sve() && + is_supported<sve_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst>(args, os); + }, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirst<sve_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst>(args); + auto strat = new sve_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst(args.cpu_info); + return new PoolingDepthfirst<__fp16>(strat, args); }, }, { PoolingMethod::DEPTHFIRST, "sve_fp16_nhwc_avg_generic_depthfirst", - [] (const PoolingArgs &args, const Nothing &) -> bool { return args.pool_type == PoolingType::AVERAGE; }, + [] (const PoolingArgs &args, const Nothing &) -> bool { + return args.cpu_info->has_sve() && args.pool_type == PoolingType::AVERAGE; + }, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirstGeneric<sve_fp16_nhwc_avg_generic_depthfirst>(args); + auto strat = new sve_fp16_nhwc_avg_generic_depthfirst(args.cpu_info); + return new PoolingDepthfirstGeneric<__fp16>(strat, args); }, }, { PoolingMethod::DEPTHFIRST, "sve_fp16_nhwc_max_generic_depthfirst", - [] (const PoolingArgs &args, const Nothing &) -> bool { return args.pool_type == PoolingType::MAX; }, + [] (const PoolingArgs &args, const Nothing &) -> bool { + return args.cpu_info->has_sve() && args.pool_type == PoolingType::MAX; + }, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirstGeneric<sve_fp16_nhwc_max_generic_depthfirst>(args); + auto strat = new sve_fp16_nhwc_max_generic_depthfirst(args.cpu_info); + return new PoolingDepthfirstGeneric<__fp16>(strat, args); }, }, -#endif // defined(__ARM_FEATURE_SVE) +#endif // defined(ARM_COMPUTE_ENABLE_SVE) #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) { PoolingMethod::DEPTHFIRST, @@ -119,7 +179,8 @@ static const PoolingImplementation<__fp16, __fp16> pooling_fp16_methods[] = { is_supported<a64_fp16_nhwc_max_2x2_s1_output2x2_depthfirst>, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirst<a64_fp16_nhwc_max_2x2_s1_output2x2_depthfirst>(args); + auto strat = new a64_fp16_nhwc_max_2x2_s1_output2x2_depthfirst(args.cpu_info); + return new PoolingDepthfirst<__fp16>(strat, args); }, }, { @@ -128,7 +189,8 @@ static const PoolingImplementation<__fp16, __fp16> pooling_fp16_methods[] = { is_supported<a64_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst>, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirst<a64_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst>(args); + auto strat = new a64_fp16_nhwc_avg_3x3_s1_output2x2_depthfirst(args.cpu_info); + return new PoolingDepthfirst<__fp16>(strat, args); }, }, { @@ -137,7 +199,8 @@ static const PoolingImplementation<__fp16, __fp16> pooling_fp16_methods[] = { [] (const PoolingArgs &args, const Nothing &) -> bool { return args.pool_type == PoolingType::AVERAGE; }, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirstGeneric<a64_fp16_nhwc_avg_generic_depthfirst>(args); + auto strat = new a64_fp16_nhwc_avg_generic_depthfirst(args.cpu_info); + return new PoolingDepthfirstGeneric<__fp16>(strat, args); }, }, { @@ -146,7 +209,8 @@ static const PoolingImplementation<__fp16, __fp16> pooling_fp16_methods[] = { [] (const PoolingArgs &args, const Nothing &) -> bool { return args.pool_type == PoolingType::MAX; }, nullptr, [] (const PoolingArgs &args, const Nothing &) -> PoolingCommon<__fp16, __fp16> * { - return new PoolingDepthfirstGeneric<a64_fp16_nhwc_max_generic_depthfirst>(args); + auto strat = new a64_fp16_nhwc_max_generic_depthfirst(args.cpu_info); + return new PoolingDepthfirstGeneric<__fp16>(strat, args); }, }, #endif // defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |