From 8a164884dddf769643cf3b9f7f94e43cb4f3c20b Mon Sep 17 00:00:00 2001 From: ramelg01 Date: Thu, 7 Apr 2022 02:42:52 +0100 Subject: =?UTF-8?q?Update=20Neon=E2=84=A2=20depthwise=20kernel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 Change-Id: Iac747f39b21c540122fa75218762631c4d787911 Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/7449 Tested-by: Arm Jenkins Reviewed-by: Andrew Mundy Reviewed-by: Sheri Zhang Comments-Addressed: Arm Jenkins --- .../kernels/arm_conv/depthwise/depthwise_fp16.cpp | 47 +++++++++++----------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'src/core/NEON/kernels/arm_conv/depthwise/depthwise_fp16.cpp') 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::max(); } - - unsigned int not_preferred_if_no_multiplier(const DepthwiseArgs &args, const Nothing &) - { - return args.channel_multiplier > 1 ? 0 : std::numeric_limits::max(); - } #endif // defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) } @@ -94,7 +91,7 @@ static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = cycle_estimate, [] (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, [] (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, [] (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, [] (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, [] (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, [] (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, [] (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, [] (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, [] (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, [] (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(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(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 }; -- cgit v1.2.1