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" |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 31 | |
| 32 | #include "depthwise_implementation_constraints.hpp" |
| 33 | |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 34 | // This can only be built if the target/compiler supports FP16 arguments. |
| 35 | #if defined(__ARM_FP16_ARGS) |
| 36 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 37 | #if defined(__aarch64__) |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 38 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
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" |
| 45 | #endif // defined(ARM_COMPUTE_ENABLE_SME2) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 46 | #include "kernels/sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst.hpp" |
| 47 | #include "kernels/sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst.hpp" |
| 48 | #include "kernels/sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst.hpp" |
| 49 | #include "kernels/sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst.hpp" |
| 50 | #include "kernels/sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp" |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 51 | #endif // defined(ARM_COMPUTE_ENABLE_SVE) |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 52 | #if defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 53 | #include "kernels/a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst.hpp" |
| 54 | #include "kernels/a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst.hpp" |
| 55 | #include "kernels/a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst.hpp" |
| 56 | #include "kernels/a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst.hpp" |
| 57 | #include "kernels/a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst.hpp" |
| 58 | #include "kernels/a64_fp16_nhwc_generic_output9_mla_depthfirst.hpp" |
| 59 | #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] | 60 | #endif // defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 61 | #endif // defined(__aarch64__) |
| 62 | |
| 63 | namespace arm_conv { |
| 64 | namespace depthwise { |
| 65 | |
| 66 | namespace |
| 67 | { |
| 68 | template <class Strategy> |
| 69 | unsigned int cycle_estimate(const DepthwiseArgs &args, const Nothing &) |
| 70 | { |
| 71 | // First-pass: compute the number of output pixels which will be computed. |
| 72 | return arm_gemm::roundup(args.output_rows, Strategy::output_rows) * |
| 73 | arm_gemm::roundup(args.output_cols, Strategy::output_cols) * |
| 74 | arm_gemm::iceildiv( |
| 75 | (long unsigned) args.input_channels * args.channel_multiplier, |
| 76 | arm_gemm::utils::get_vector_length<typename Strategy::return_type>(Strategy::vl_type) |
| 77 | ); |
| 78 | } |
| 79 | |
Michael Tyler | 74921ee | 2023-04-12 17:43:17 +0100 | [diff] [blame^] | 80 | template <class Strategy> |
| 81 | unsigned int planar_cycle_estimate(const DepthwiseArgs &args, const Nothing &) |
| 82 | { |
| 83 | // First-pass: compute the number of output pixels which will be computed. |
| 84 | return arm_gemm::roundup(args.output_rows, Strategy::output_rows) * |
| 85 | args.output_cols * |
| 86 | arm_gemm::iceildiv( |
| 87 | (long unsigned) args.input_channels * args.channel_multiplier, |
| 88 | arm_gemm::utils::get_vector_length<typename Strategy::return_type>(Strategy::vl_type) |
| 89 | ); |
| 90 | } |
| 91 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 92 | #if defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 93 | unsigned int not_preferred(const DepthwiseArgs &, const Nothing &) __attribute__ ((unused)); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 94 | unsigned int not_preferred(const DepthwiseArgs &, const Nothing &) |
| 95 | { |
| 96 | return std::numeric_limits<unsigned int>::max(); |
| 97 | } |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 98 | #endif // defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 101 | static const DepthwiseImplementation<__fp16, __fp16> depthwise_fp16_methods[] = { |
| 102 | #if defined(__aarch64__) |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 103 | #if defined(ARM_COMPUTE_ENABLE_SVE) |
David Mansell | b2758f3 | 2023-03-30 19:10:52 +0100 | [diff] [blame] | 104 | #if defined(ARM_COMPUTE_ENABLE_SME2) |
| 105 | { |
| 106 | DepthwiseMethod::DEPTHFIRST, |
| 107 | "sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst", |
| 108 | constraint(is_supported<sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
| 109 | has_no_channel_multiplier, |
| 110 | cpu_has_sme2), |
| 111 | cycle_estimate<sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
| 112 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 113 | auto strat = new sme2_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst(args.cpu_info); |
| 114 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 115 | }, |
| 116 | }, |
| 117 | { |
| 118 | DepthwiseMethod::DEPTHFIRST, |
| 119 | "sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst", |
| 120 | constraint(is_supported<sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
| 121 | has_no_channel_multiplier, |
| 122 | cpu_has_sme2), |
| 123 | cycle_estimate<sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
| 124 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 125 | auto strat = new sme2_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst(args.cpu_info); |
| 126 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 127 | }, |
| 128 | }, |
| 129 | { |
| 130 | DepthwiseMethod::DEPTHFIRST, |
| 131 | "sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst", |
| 132 | constraint(is_supported<sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
| 133 | has_no_channel_multiplier, |
| 134 | cpu_has_sme2), |
| 135 | cycle_estimate<sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
| 136 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 137 | auto strat = new sme2_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst(args.cpu_info); |
| 138 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 139 | }, |
| 140 | }, |
| 141 | { |
| 142 | DepthwiseMethod::DEPTHFIRST, |
| 143 | "sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst", |
| 144 | constraint(is_supported<sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
| 145 | has_no_channel_multiplier, |
| 146 | cpu_has_sme2), |
| 147 | cycle_estimate<sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
| 148 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 149 | auto strat = new sme2_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst(args.cpu_info); |
| 150 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 151 | }, |
| 152 | }, |
| 153 | { |
| 154 | DepthwiseMethod::DEPTHFIRST, |
| 155 | "sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst", |
| 156 | constraint(is_supported<sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
| 157 | has_no_channel_multiplier, |
| 158 | cpu_has_sme2), |
| 159 | cycle_estimate<sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
| 160 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
| 161 | auto strat = new sme2_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst(args.cpu_info); |
| 162 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
| 163 | }, |
| 164 | }, |
| 165 | #endif // defined(ARM_COMPUTE_ENABLE_SME2) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 166 | { |
| 167 | DepthwiseMethod::DEPTHFIRST, |
| 168 | "sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst", |
| 169 | constraint(is_supported<sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 170 | has_no_channel_multiplier, |
| 171 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 172 | cycle_estimate<sve_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
| 173 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 174 | 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] | 175 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 176 | }, |
| 177 | }, |
| 178 | { |
| 179 | DepthwiseMethod::DEPTHFIRST, |
| 180 | "sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst", |
| 181 | constraint(is_supported<sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 182 | has_no_channel_multiplier, |
| 183 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 184 | cycle_estimate<sve_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
| 185 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 186 | 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] | 187 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 188 | }, |
| 189 | }, |
| 190 | { |
| 191 | DepthwiseMethod::DEPTHFIRST, |
| 192 | "sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst", |
| 193 | constraint(is_supported<sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 194 | has_no_channel_multiplier, |
| 195 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 196 | cycle_estimate<sve_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
| 197 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 198 | 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] | 199 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 200 | }, |
| 201 | }, |
| 202 | { |
| 203 | DepthwiseMethod::DEPTHFIRST, |
| 204 | "sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst", |
| 205 | constraint(is_supported<sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 206 | has_no_channel_multiplier, |
| 207 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 208 | cycle_estimate<sve_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
| 209 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 210 | 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] | 211 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 212 | }, |
| 213 | }, |
| 214 | { |
| 215 | DepthwiseMethod::DEPTHFIRST, |
| 216 | "sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst", |
| 217 | constraint(is_supported<sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 218 | has_no_channel_multiplier, |
| 219 | cpu_has_sve), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 220 | cycle_estimate<sve_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
| 221 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 222 | 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] | 223 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 224 | }, |
| 225 | }, |
Michalis Spyrou | 20fca52 | 2021-06-07 14:23:57 +0100 | [diff] [blame] | 226 | #endif // defined(ARM_COMPUTE_ENABLE_SVE) |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 227 | #if defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 228 | { |
| 229 | DepthwiseMethod::DEPTHFIRST, |
| 230 | "a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst", |
| 231 | constraint(is_supported<a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 232 | has_no_channel_multiplier, |
| 233 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 234 | cycle_estimate<a64_fp16_nhwc_3x3_s1_output4x4_mla_depthfirst>, |
| 235 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 236 | 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] | 237 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 238 | }, |
| 239 | }, |
| 240 | { |
| 241 | DepthwiseMethod::DEPTHFIRST, |
| 242 | "a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst", |
| 243 | constraint(is_supported<a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 244 | has_no_channel_multiplier, |
| 245 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 246 | cycle_estimate<a64_fp16_nhwc_3x3_s1_output3x3_mla_depthfirst>, |
| 247 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 248 | 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] | 249 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 250 | }, |
| 251 | }, |
| 252 | { |
| 253 | DepthwiseMethod::DEPTHFIRST, |
| 254 | "a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst", |
| 255 | constraint(is_supported<a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 256 | has_no_channel_multiplier, |
| 257 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 258 | cycle_estimate<a64_fp16_nhwc_3x3_s1_output2x2_mla_depthfirst>, |
| 259 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 260 | 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] | 261 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 262 | }, |
| 263 | }, |
| 264 | { |
| 265 | DepthwiseMethod::DEPTHFIRST, |
| 266 | "a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst", |
| 267 | constraint(is_supported<a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 268 | has_no_channel_multiplier, |
| 269 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 270 | cycle_estimate<a64_fp16_nhwc_3x3_s2_output2x2_mla_depthfirst>, |
| 271 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 272 | 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] | 273 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 274 | }, |
| 275 | }, |
| 276 | { |
| 277 | DepthwiseMethod::DEPTHFIRST, |
| 278 | "a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst", |
| 279 | constraint(is_supported<a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 280 | has_no_channel_multiplier, |
| 281 | cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 282 | cycle_estimate<a64_fp16_nhwc_5x5_s1_output2x2_mla_depthfirst>, |
| 283 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 284 | 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] | 285 | return new DepthwiseDepthfirst<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 286 | }, |
| 287 | }, |
| 288 | { |
| 289 | DepthwiseMethod::DEPTHFIRST, |
| 290 | "a64_fp16_nhwc_generic_output3x3_mla_depthfirst", |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 291 | constraint(has_no_channel_multiplier, cpu_has_fp16), |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 292 | not_preferred, |
| 293 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 294 | auto kern = new a64_fp16_nhwc_generic_output9_mla_depthfirst(args.cpu_info); |
| 295 | auto strat = new GenericDepthfirstStrategy<__fp16>(kern, 3, 3, args); |
| 296 | return new DepthwiseDepthfirstGeneric<__fp16>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 297 | }, |
| 298 | }, |
| 299 | { |
| 300 | DepthwiseMethod::DEPTHFIRST, |
| 301 | "a64_fp16_nhwc_generic_with_multiplier_output2x8_mla_depthfirst", |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 302 | constraint(cpu_has_fp16, has_channel_multiplier), |
| 303 | nullptr, |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 304 | [] (const DepthwiseArgs &args, const Nothing &) -> DepthwiseCommon<__fp16, __fp16, __fp16> * { |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 305 | auto kern = new a64_fp16_packed_to_nhwc_generic_with_multiplier_output2x8_mla_depthfirst(args.cpu_info); |
| 306 | auto strat = new GenericDepthfirstMultiplierStrategy<__fp16>(kern, args); |
| 307 | return new DepthwiseDepthfirstMultiplier<__fp16, __fp16, __fp16, __fp16, true>(strat, args); |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 308 | }, |
| 309 | }, |
ramelg01 | 8a16488 | 2022-04-07 02:42:52 +0100 | [diff] [blame] | 310 | #endif // defined(ENABLE_FP16_KERNELS) && defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC) |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 311 | #endif // defined(__aarch64__) |
| 312 | { DepthwiseMethod::DEFAULT, "", nullptr, nullptr, nullptr }, // End of list |
| 313 | }; |
| 314 | |
| 315 | template <> |
| 316 | const DepthwiseImplementation<__fp16> *depthwise_implementation_list() |
| 317 | { |
| 318 | return depthwise_fp16_methods; |
| 319 | } |
| 320 | |
| 321 | template UniqueDepthwiseCommon<__fp16> depthwise(const DepthwiseArgs &, const Nothing &); |
| 322 | template std::vector<KernelDescription> get_compatible_kernels<__fp16>(const DepthwiseArgs &, const Nothing &); |
| 323 | |
Michele Di Giorgio | d02d5ed | 2021-01-22 09:47:04 +0000 | [diff] [blame] | 324 | } // namespace depthwise |
| 325 | } // namespace arm_conv |
Freddie Liardet | d216f57 | 2021-08-03 15:57:32 +0100 | [diff] [blame] | 326 | |
| 327 | #endif // defined(__ARM_FP16_ARGS) |