diff options
author | ramelg01 <ramy.elgammal@arm.com> | 2022-04-07 02:42:52 +0100 |
---|---|---|
committer | Ramy Elgammal <ramy.elgammal@arm.com> | 2022-04-26 15:51:22 +0000 |
commit | 8a164884dddf769643cf3b9f7f94e43cb4f3c20b (patch) | |
tree | 35958dd48b6df1a851c880dad2b2ce285671b611 /src/core/NEON/kernels/arm_conv/depthwise/depthwise_fp16.cpp | |
parent | c827e99fc46521f43719b0c2d1b6f05d66abf68c (diff) | |
download | ComputeLibrary-8a164884dddf769643cf3b9f7f94e43cb4f3c20b.tar.gz |
Update Neon™ depthwise kernel
- Reduce duplication and simplify overall structure.
- Improve multi-threaded performance by sharing more data
in lower-level caches.
Partially Resolves: COMPMID-5054
Signed-off-by: Ramy Elgammal <ramy.elgammal@arm.com>
Change-Id: Iac747f39b21c540122fa75218762631c4d787911
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7449
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Andrew Mundy
Reviewed-by: Sheri Zhang <sheri.zhang@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/core/NEON/kernels/arm_conv/depthwise/depthwise_fp16.cpp')
-rw-r--r-- | src/core/NEON/kernels/arm_conv/depthwise/depthwise_fp16.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/core/NEON/kernels/arm_conv/depthwise/depthwise_fp16.cpp b/src/core/NEON/kernels/arm_conv/depthwise/depthwise_fp16.cpp index 934272a0ac..6b100d9d61 100644 --- a/src/core/NEON/kernels/arm_conv/depthwise/depthwise_fp16.cpp +++ b/src/core/NEON/kernels/arm_conv/depthwise/depthwise_fp16.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Arm Limited. + * Copyright (c) 2021-2022 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -28,7 +28,6 @@ #include "depthwise_depthfirst.hpp" #include "depthwise_depthfirst_generic.hpp" #include "depthwise_depthfirst_multiplier.hpp" -#include "depthwise_depthfirst_generic_multiplier.hpp" #include "depthwise_implementation_constraints.hpp" @@ -43,6 +42,7 @@ #include "kernels/sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst.hpp" #include "kernels/sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp" #endif // defined(ARM_COMPUTE_ENABLE_SVE) +#if defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) #include "kernels/a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst.hpp" #include "kernels/a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst.hpp" #include "kernels/a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst.hpp" @@ -50,6 +50,7 @@ #include "kernels/a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp" #include "kernels/a64_fp16_nhwc_generic_output9_mla_depthfirst.hpp" #include "kernels/a64_fp16_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst.hpp" +#endif // defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) #endif // defined(__aarch64__) namespace arm_conv { @@ -70,15 +71,11 @@ namespace } #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) + unsigned int not_preferred(const DepthwiseArgs &, const Nothing &) __attribute__ ((unused)); unsigned int not_preferred(const DepthwiseArgs &, const Nothing &) { return std::numeric_limits<unsigned int>::max(); } - - unsigned int not_preferred_if_no_multiplier(const DepthwiseArgs &args, const Nothing &) - { - return args.channel_multiplier > 1 ? 0 : std::numeric_limits<unsigned int>::max(); - } #endif // defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) } @@ -94,7 +91,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -106,7 +103,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -118,7 +115,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -130,7 +127,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -142,11 +139,11 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, #endif // defined(ARM_COMPUTE_ENABLE_SVE) -#if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) +#if defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) { DepthwiseMethod::DEPTHFIRST, "a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst", @@ -156,7 +153,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -168,7 +165,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -180,7 +177,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -192,7 +189,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -204,7 +201,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate<a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { auto strat = new a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst(args.cpu_info); - return new DepthwiseDepthfirst<__fp16, __fp16, __fp16, __fp16>(strat, args); + return new DepthwiseDepthfirst<__fp16>(strat, args); }, }, { @@ -213,19 +210,23 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = constraint(has_no_channel_multiplier, cpu_has_fp16), not_preferred, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { - return new DepthwiseDepthfirstGeneric<a64_fp16_nhwc_generic_output9_mla_depthfirst, 3, 3>(args); + auto kern = new a64_fp16_nhwc_generic_output9_mla_depthfirst(args.cpu_info); + auto strat = new GenericDepthfirstStrategy<__fp16>(kern, 3, 3, args); + return new DepthwiseDepthfirstGeneric<__fp16>(strat, args); }, }, { DepthwiseMethod::DEPTHFIRST, "a64_fp16_nhwc_generic_with_multiplier_output2x8_mla_depthfirst", - constraint(cpu_has_fp16), - not_preferred_if_no_multiplier, + constraint(cpu_has_fp16, has_channel_multiplier), + nullptr, [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { - return new DepthwiseDepthfirstGenericWithMultiplier<a64_fp16_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst>(args); + auto kern = new a64_fp16_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst(args.cpu_info); + auto strat = new GenericDepthfirstMultiplierStrategy<__fp16>(kern, args); + return new DepthwiseDepthfirstMultiplier<__fp16, __fp16, __fp16, __fp16, true>(strat, args); }, }, -#endif // defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) +#endif // defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) #endif // defined(__aarch64__) { DepthwiseMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list }; |