Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 1 | /* |
Michael Tyler | 74921ee | 2023-04-12 17:43:17 +0100 | [diff] [blame] | 2 | * Copyright (c) 2021-2023 Arm Limited. |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | |
| 25 | #include "arm_gemm_local.hpp" |
| 26 | |
| 27 | #include "depthwise_implementation.hpp" |
| 28 | #include "depthwise_depthfirst.hpp" |
| 29 | #include "depthwise_depthfirst_generic.hpp" |
| 30 | #include "depthwise_depthfirst_multiplier.hpp" |
Michael Tyler | 8deee9b | 2023-06-30 11:26:05 +0100 | [diff] [blame] | 31 | #include "depthwise_planar.hpp" |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 32 | |
| 33 | #include "depthwise_implementation_constraints.hpp" |
| 34 | |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 35 | // This can only be built if the target/compiler supports FP16 arguments. |
| 36 | #if defined(__ARM_FP16_ARGS) |
| 37 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 38 | #if defined(__aarch64__) |
David Mansell | b2758f3 | 2023-03-30 19:10:52 +0100 | [diff] [blame] | 39 | #if defined(ARM_COMPUTE_ENABLE_SME2) |
| 40 | #include "kernels/sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst.hpp" |
| 41 | #include "kernels/sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst.hpp" |
| 42 | #include "kernels/sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst.hpp" |
| 43 | #include "kernels/sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst.hpp" |
| 44 | #include "kernels/sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp" |
Michael Tyler | 8deee9b | 2023-06-30 11:26:05 +0100 | [diff] [blame] | 45 | #endif // defined(ARM_COMPUTE_ENABLE_SME2) |
| 46 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 47 | #include "kernels/sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst.hpp" |
| 48 | #include "kernels/sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst.hpp" |
| 49 | #include "kernels/sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst.hpp" |
| 50 | #include "kernels/sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst.hpp" |
| 51 | #include "kernels/sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp" |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 52 | #endif // defined(ARM_COMPUTE_ENABLE_SVE) |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 53 | #if defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 54 | #include "kernels/a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst.hpp" |
| 55 | #include "kernels/a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst.hpp" |
| 56 | #include "kernels/a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst.hpp" |
| 57 | #include "kernels/a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst.hpp" |
| 58 | #include "kernels/a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp" |
| 59 | #include "kernels/a64_fp16_nhwc_generic_output9_mla_depthfirst.hpp" |
| 60 | #include "kernels/a64_fp16_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst.hpp" |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 61 | #endif // defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 62 | #endif // defined(__aarch64__) |
| 63 | |
| 64 | namespace arm_conv { |
| 65 | namespace depthwise { |
| 66 | |
| 67 | namespace |
| 68 | { |
Michael Tyler | 4c30de0 | 2023-07-07 12:01:32 +0100 | [diff] [blame] | 69 | #if defined(__aarch64__) |
| 70 | #if defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 71 | bool prefer_premultiply(const DepthwiseArgs &args) { |
| 72 | if ((args.stride_rows != args.stride_cols) || (args.kernel_rows != args.kernel_cols)) |
| 73 | { |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | unsigned int threshold; |
| 78 | |
| 79 | if (args.stride_rows == 1 && args.kernel_rows == 3) |
| 80 | { |
| 81 | threshold = 30; |
| 82 | } |
| 83 | else if (args.stride_rows == 1 && args.kernel_rows == 5) |
| 84 | { |
| 85 | threshold = 31; |
| 86 | } |
| 87 | else if (args.stride_rows == 2 && args.kernel_rows == 3) |
| 88 | { |
| 89 | threshold = 11; |
| 90 | } |
| 91 | else if (args.stride_rows == 2 && args.kernel_rows == 5) |
| 92 | { |
| 93 | threshold = 19; |
| 94 | } else |
| 95 | { |
| 96 | return false; |
| 97 | } |
| 98 | |
| 99 | return args.channel_multiplier <= threshold; |
| 100 | } |
| 101 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 102 | template <class Strategy> |
| 103 | unsigned int cycle_estimate(const DepthwiseArgs &args, const Nothing &) |
| 104 | { |
Michael Tyler | 4c30de0 | 2023-07-07 12:01:32 +0100 | [diff] [blame] | 105 | if (args.channel_multiplier > 1 && !prefer_premultiply(args)) |
| 106 | { |
| 107 | return std::numeric_limits<unsigned int>::max(); |
| 108 | } |
| 109 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 110 | // First-pass: compute the number of output pixels which will be computed. |
| 111 | return arm_gemm::roundup(args.output_rows, Strategy::output_rows) * |
| 112 | arm_gemm::roundup(args.output_cols, Strategy::output_cols) * |
| 113 | arm_gemm::iceildiv( |
| 114 | (long unsigned) args.input_channels * args.channel_multiplier, |
| 115 | arm_gemm::utils::get_vector_length<typename Strategy::return_type>(Strategy::vl_type) |
| 116 | ); |
| 117 | } |
| 118 | |
Michael Tyler | 74921ee | 2023-04-12 17:43:17 +0100 | [diff] [blame] | 119 | template <class Strategy> |
| 120 | unsigned int planar_cycle_estimate(const DepthwiseArgs &args, const Nothing &) |
| 121 | { |
| 122 | // First-pass: compute the number of output pixels which will be computed. |
| 123 | return arm_gemm::roundup(args.output_rows, Strategy::output_rows) * |
| 124 | args.output_cols * |
| 125 | arm_gemm::iceildiv( |
| 126 | (long unsigned) args.input_channels * args.channel_multiplier, |
| 127 | arm_gemm::utils::get_vector_length<typename Strategy::return_type>(Strategy::vl_type) |
| 128 | ); |
| 129 | } |
| 130 | |
Michael Tyler | 4c30de0 | 2023-07-07 12:01:32 +0100 | [diff] [blame] | 131 | unsigned int multiplier_cycle_estimate(const DepthwiseArgs &args, const Nothing &) |
| 132 | { |
| 133 | return prefer_premultiply(args)? std::numeric_limits<unsigned int>::max() : 0; |
| 134 | } |
| 135 | |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 136 | unsigned int not_preferred(const DepthwiseArgs &, const Nothing &) __attribute__ ((unused)); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 137 | unsigned int not_preferred(const DepthwiseArgs &, const Nothing &) |
| 138 | { |
| 139 | return std::numeric_limits<unsigned int>::max(); |
| 140 | } |
Michael Tyler | 4c30de0 | 2023-07-07 12:01:32 +0100 | [diff] [blame] | 141 | #endif // defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
| 142 | #endif // defined(__aarch64__) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 143 | } |
| 144 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 145 | static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = { |
| 146 | #if defined(__aarch64__) |
Michael Tyler | 7a31a82 | 2023-06-06 17:31:44 +0100 | [diff] [blame] | 147 | #if defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 148 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
David Mansell | b2758f3 | 2023-03-30 19:10:52 +0100 | [diff] [blame] | 149 | #if defined(ARM_COMPUTE_ENABLE_SME2) |
| 150 | { |
| 151 | DepthwiseMethod::DEPTHFIRST, |
| 152 | "sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst", |
| 153 | constraint(is_supported<sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
David Mansell | b2758f3 | 2023-03-30 19:10:52 +0100 | [diff] [blame] | 154 | cpu_has_sme2), |
| 155 | cycle_estimate<sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
| 156 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 157 | auto strat = new sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst(args.cpu_info); |
| 158 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 159 | }, |
| 160 | }, |
| 161 | { |
| 162 | DepthwiseMethod::DEPTHFIRST, |
| 163 | "sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst", |
| 164 | constraint(is_supported<sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
David Mansell | b2758f3 | 2023-03-30 19:10:52 +0100 | [diff] [blame] | 165 | cpu_has_sme2), |
| 166 | cycle_estimate<sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
| 167 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 168 | auto strat = new sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst(args.cpu_info); |
| 169 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 170 | }, |
| 171 | }, |
| 172 | { |
| 173 | DepthwiseMethod::DEPTHFIRST, |
| 174 | "sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst", |
| 175 | constraint(is_supported<sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
David Mansell | b2758f3 | 2023-03-30 19:10:52 +0100 | [diff] [blame] | 176 | cpu_has_sme2), |
| 177 | cycle_estimate<sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
| 178 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 179 | auto strat = new sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst(args.cpu_info); |
| 180 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 181 | }, |
| 182 | }, |
| 183 | { |
| 184 | DepthwiseMethod::DEPTHFIRST, |
| 185 | "sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst", |
| 186 | constraint(is_supported<sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
David Mansell | b2758f3 | 2023-03-30 19:10:52 +0100 | [diff] [blame] | 187 | cpu_has_sme2), |
| 188 | cycle_estimate<sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
| 189 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 190 | auto strat = new sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst(args.cpu_info); |
| 191 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 192 | }, |
| 193 | }, |
| 194 | { |
| 195 | DepthwiseMethod::DEPTHFIRST, |
| 196 | "sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst", |
| 197 | constraint(is_supported<sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
David Mansell | b2758f3 | 2023-03-30 19:10:52 +0100 | [diff] [blame] | 198 | cpu_has_sme2), |
| 199 | cycle_estimate<sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
| 200 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 201 | auto strat = new sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst(args.cpu_info); |
| 202 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 203 | }, |
| 204 | }, |
Michael Tyler | 8deee9b | 2023-06-30 11:26:05 +0100 | [diff] [blame] | 205 | #endif // defined(ARM_COMPUTE_ENABLE_SME2) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 206 | { |
| 207 | DepthwiseMethod::DEPTHFIRST, |
| 208 | "sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst", |
| 209 | constraint(is_supported<sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 210 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 211 | cycle_estimate<sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
| 212 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 213 | auto strat = new sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 214 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 215 | }, |
| 216 | }, |
| 217 | { |
| 218 | DepthwiseMethod::DEPTHFIRST, |
| 219 | "sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst", |
| 220 | constraint(is_supported<sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 221 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 222 | cycle_estimate<sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
| 223 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 224 | auto strat = new sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 225 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 226 | }, |
| 227 | }, |
| 228 | { |
| 229 | DepthwiseMethod::DEPTHFIRST, |
| 230 | "sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst", |
| 231 | constraint(is_supported<sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 232 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 233 | cycle_estimate<sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
| 234 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 235 | auto strat = new sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 236 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 237 | }, |
| 238 | }, |
| 239 | { |
| 240 | DepthwiseMethod::DEPTHFIRST, |
| 241 | "sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst", |
| 242 | constraint(is_supported<sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 243 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 244 | cycle_estimate<sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
| 245 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 246 | auto strat = new sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 247 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 248 | }, |
| 249 | }, |
| 250 | { |
| 251 | DepthwiseMethod::DEPTHFIRST, |
| 252 | "sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst", |
| 253 | constraint(is_supported<sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 254 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 255 | cycle_estimate<sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
| 256 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 257 | auto strat = new sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 258 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 259 | }, |
| 260 | }, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 261 | #endif // defined(ARM_COMPUTE_ENABLE_SVE) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 262 | { |
| 263 | DepthwiseMethod::DEPTHFIRST, |
| 264 | "a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst", |
| 265 | constraint(is_supported<a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 266 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 267 | cycle_estimate<a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
| 268 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 269 | auto strat = new a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 270 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 271 | }, |
| 272 | }, |
| 273 | { |
| 274 | DepthwiseMethod::DEPTHFIRST, |
| 275 | "a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst", |
| 276 | constraint(is_supported<a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 277 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 278 | cycle_estimate<a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
| 279 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 280 | auto strat = new a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 281 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 282 | }, |
| 283 | }, |
| 284 | { |
| 285 | DepthwiseMethod::DEPTHFIRST, |
| 286 | "a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst", |
| 287 | constraint(is_supported<a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 288 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 289 | cycle_estimate<a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
| 290 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 291 | auto strat = new a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 292 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 293 | }, |
| 294 | }, |
| 295 | { |
| 296 | DepthwiseMethod::DEPTHFIRST, |
| 297 | "a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst", |
| 298 | constraint(is_supported<a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 299 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 300 | cycle_estimate<a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
| 301 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 302 | auto strat = new a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 303 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 304 | }, |
| 305 | }, |
| 306 | { |
| 307 | DepthwiseMethod::DEPTHFIRST, |
| 308 | "a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst", |
| 309 | constraint(is_supported<a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 310 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 311 | cycle_estimate<a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
| 312 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 313 | auto strat = new a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst(args.cpu_info); |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 314 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 315 | }, |
| 316 | }, |
| 317 | { |
| 318 | DepthwiseMethod::DEPTHFIRST, |
| 319 | "a64_fp16_nhwc_generic_output3x3_mla_depthfirst", |
Michael Tyler | 8deee9b | 2023-06-30 11:26:05 +0100 | [diff] [blame] | 320 | constraint(cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 321 | not_preferred, |
| 322 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 323 | auto kern = new a64_fp16_nhwc_generic_output9_mla_depthfirst(args.cpu_info); |
| 324 | auto strat = new GenericDepthfirstStrategy<__fp16>(kern, 3, 3, args); |
| 325 | return new DepthwiseDepthfirstGeneric<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 326 | }, |
| 327 | }, |
| 328 | { |
| 329 | DepthwiseMethod::DEPTHFIRST, |
| 330 | "a64_fp16_nhwc_generic_with_multiplier_output2x8_mla_depthfirst", |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 331 | constraint(cpu_has_fp16, has_channel_multiplier), |
Michael Tyler | 4c30de0 | 2023-07-07 12:01:32 +0100 | [diff] [blame] | 332 | multiplier_cycle_estimate, |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 333 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 334 | auto kern = new a64_fp16_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst(args.cpu_info); |
| 335 | auto strat = new GenericDepthfirstMultiplierStrategy<__fp16>(kern, args); |
| 336 | return new DepthwiseDepthfirstMultiplier<__fp16, __fp16, __fp16, __fp16, true>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 337 | }, |
| 338 | }, |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 339 | #endif // defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 340 | #endif // defined(__aarch64__) |
| 341 | { DepthwiseMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list |
| 342 | }; |
| 343 | |
| 344 | template <> |
| 345 | const DepthwiseImplementation<__fp16> *depthwise_implementation_list() |
| 346 | { |
| 347 | return depthwise_fp16_methods; |
| 348 | } |
| 349 | |
| 350 | template UniqueDepthwiseCommon<__fp16> depthwise(const DepthwiseArgs &, const Nothing &); |
| 351 | template std::vector<KernelDescription> get_compatible_kernels<__fp16>(const DepthwiseArgs &, const Nothing &); |
| 352 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 353 | } // namespace depthwise |
| 354 | } // namespace arm_conv |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 355 | |
| 356 | #endif // defined(__ARM_FP16_ARGS) |