Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022 Arm Limited. |
| 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 | */ |
Ramy Elgammal | df6a3b0 | 2022-11-30 16:23:10 +0000 | [diff] [blame] | 24 | #include "src/runtime/heuristics/direct_conv/ClDirectConvDefaultConfigValhall.h" |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 25 | |
| 26 | #include "arm_compute/core/CL/CLHelpers.h" |
| 27 | #include "arm_compute/core/CL/CLKernelLibrary.h" |
| 28 | #include "arm_compute/core/GPUTarget.h" |
| 29 | #include "arm_compute/core/TensorInfo.h" |
| 30 | #include "arm_compute/core/TensorShape.h" |
| 31 | #include "arm_compute/core/utils/misc/ShapeCalculator.h" |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 32 | |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 33 | #include <utility> |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace cl_direct_conv |
| 38 | { |
| 39 | using namespace arm_compute::misc::shape_calculator; |
| 40 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 41 | ClDirectConvDefaultConfigValhall::ClDirectConvDefaultConfigValhall(GPUTarget gpu) : IClDirectConvKernelConfig(gpu) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 42 | { |
| 43 | } |
| 44 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 45 | DirectConvComputeKernelInfo ClDirectConvDefaultConfigValhall::configure(const ITensorInfo *src, |
| 46 | const ITensorInfo *wei, |
| 47 | const PadStrideInfo &conv_info) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 48 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 49 | using ConfigurationFunctionExecutorPtr = DirectConvComputeKernelInfo (ClDirectConvDefaultConfigValhall::*)( |
| 50 | const ITensorInfo *src, const ITensorInfo *wei, const PadStrideInfo &conv_info); |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 51 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 52 | ClDirectConvConfigArray<ConfigurationFunctionExecutorPtr> configs_G78( |
| 53 | &ClDirectConvDefaultConfigValhall::configure_G78_f32, &ClDirectConvDefaultConfigValhall::configure_G78_f16, |
| 54 | &ClDirectConvDefaultConfigValhall::configure_G78_u8); |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 55 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 56 | ClDirectConvConfigArray<ConfigurationFunctionExecutorPtr> configs_G57( |
| 57 | &ClDirectConvDefaultConfigValhall::configure_G57_f32, &ClDirectConvDefaultConfigValhall::configure_G57_f16, |
| 58 | &ClDirectConvDefaultConfigValhall::configure_G78_u8); |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 59 | |
| 60 | ConfigurationFunctionExecutorPtr func = nullptr; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 61 | switch (_target) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 62 | { |
| 63 | case GPUTarget::G57: |
| 64 | func = configs_G57.get_function(src->data_type()); |
| 65 | break; |
| 66 | case GPUTarget::G78: |
| 67 | default: |
| 68 | func = configs_G78.get_function(src->data_type()); |
| 69 | break; |
| 70 | } |
| 71 | |
| 72 | ARM_COMPUTE_ERROR_ON_MSG(func == nullptr, "Data type not supported for direct convolution"); |
| 73 | return (this->*func)(src, wei, conv_info); |
| 74 | } |
| 75 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 76 | DirectConvComputeKernelInfo ClDirectConvDefaultConfigValhall::configure_G78_f32(const ITensorInfo *src, |
| 77 | const ITensorInfo *wei, |
| 78 | const PadStrideInfo &conv_info) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 79 | { |
| 80 | DirectConvComputeKernelInfo desc; |
| 81 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 82 | if (src->data_layout() == DataLayout::NHWC) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 83 | { |
| 84 | // Get the output shape |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 85 | const TensorShape wei_shape = wei->tensor_shape(); |
| 86 | const TensorShape dst_shape = misc::shape_calculator::compute_deep_convolution_shape(*src, *wei, conv_info); |
Gian Marco Iodice | ad9a7ed | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 87 | const bool export_weights_to_cl_image = export_to_cl_image(wei); |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 88 | |
| 89 | const int32_t ofm = dst_shape[0]; |
| 90 | const int32_t m = dst_shape[1] * dst_shape[2]; |
| 91 | const bool is_pointwise = (wei_shape[1] == wei_shape[2]) && wei_shape[1] == 1; |
| 92 | |
Gian Marco Iodice | ad9a7ed | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 93 | desc.export_weights_to_cl_image = export_weights_to_cl_image; |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 94 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 95 | if (dst_shape[0] <= 4) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 96 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 97 | if (is_pointwise) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 98 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 99 | if (ofm == 4) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 100 | { |
| 101 | desc.m0 = 1; |
| 102 | desc.n0 = 4; |
| 103 | desc.k0 = 16; |
| 104 | } |
| 105 | else |
| 106 | { |
| 107 | desc.m0 = 1; |
| 108 | desc.n0 = 1; |
| 109 | desc.k0 = 16; |
| 110 | } |
| 111 | } |
| 112 | else |
| 113 | { |
| 114 | desc.m0 = 1; |
| 115 | desc.n0 = 2; |
| 116 | desc.k0 = 16; |
| 117 | } |
| 118 | } |
| 119 | else |
| 120 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 121 | if (m < 64) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 122 | { |
| 123 | desc.m0 = 1; |
| 124 | desc.n0 = 1; |
| 125 | desc.k0 = 16; |
| 126 | } |
| 127 | else |
| 128 | { |
| 129 | desc.m0 = 4; |
| 130 | desc.n0 = 4; |
| 131 | desc.k0 = 4; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | return desc; |
| 137 | } |
| 138 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 139 | DirectConvComputeKernelInfo ClDirectConvDefaultConfigValhall::configure_G78_f16(const ITensorInfo *src, |
| 140 | const ITensorInfo *wei, |
| 141 | const PadStrideInfo &conv_info) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 142 | { |
| 143 | DirectConvComputeKernelInfo desc; |
| 144 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 145 | if (src->data_layout() == DataLayout::NHWC) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 146 | { |
| 147 | // Get the output shape |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 148 | const TensorShape wei_shape = wei->tensor_shape(); |
| 149 | const TensorShape dst_shape = misc::shape_calculator::compute_deep_convolution_shape(*src, *wei, conv_info); |
Gian Marco Iodice | ad9a7ed | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 150 | const bool export_weights_to_cl_image = export_to_cl_image(wei); |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 151 | |
| 152 | const int32_t ofm = dst_shape[0]; |
| 153 | const int32_t m = dst_shape[1] * dst_shape[2]; |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 154 | const int32_t k = wei_shape[0]; |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 155 | const bool is_pointwise = (wei_shape[1] == wei_shape[2]) && wei_shape[1] == 1; |
| 156 | |
Gian Marco Iodice | ad9a7ed | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 157 | desc.export_weights_to_cl_image = export_weights_to_cl_image; |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 158 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 159 | if (dst_shape[0] <= 4) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 160 | { |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 161 | // k0 should be as larger as possible. However, we should avoid |
| 162 | // having left-over for loops that make the implementation slower. |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 163 | if ((k % 16) == 0) |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 164 | { |
| 165 | desc.k0 = 16; |
| 166 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 167 | else if ((k % 8) == 0) |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 168 | { |
| 169 | desc.k0 = 8; |
| 170 | } |
| 171 | else |
| 172 | { |
| 173 | desc.k0 = 4; |
| 174 | } |
| 175 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 176 | if (is_pointwise) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 177 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 178 | if (ofm == 4) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 179 | { |
| 180 | desc.m0 = 1; |
| 181 | desc.n0 = 4; |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 182 | } |
| 183 | else |
| 184 | { |
| 185 | desc.m0 = 1; |
| 186 | desc.n0 = 1; |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 187 | } |
| 188 | } |
| 189 | else |
| 190 | { |
| 191 | desc.m0 = 1; |
| 192 | desc.n0 = dst_shape[0]; |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 193 | } |
| 194 | } |
| 195 | else |
| 196 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 197 | if (m < 64) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 198 | { |
| 199 | desc.m0 = 1; |
| 200 | desc.n0 = 1; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 201 | if ((k % 16) == 0) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 202 | { |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 203 | desc.k0 = 16; |
| 204 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 205 | else if ((k % 8) == 0) |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 206 | { |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 207 | desc.k0 = 8; |
| 208 | } |
| 209 | else |
| 210 | { |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 211 | desc.k0 = 4; |
| 212 | } |
| 213 | } |
| 214 | else |
| 215 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 216 | if (ofm >= 16) |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 217 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 218 | if (m / 6 > 24000) |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 219 | { |
| 220 | desc.m0 = 6; |
| 221 | } |
| 222 | else |
| 223 | { |
| 224 | desc.m0 = 5; |
| 225 | } |
| 226 | desc.n0 = 8; |
| 227 | desc.k0 = 4; |
| 228 | } |
| 229 | else |
| 230 | { |
| 231 | desc.m0 = 2; |
| 232 | desc.n0 = 8; |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 233 | if ((k % 16) == 0) |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 234 | { |
| 235 | desc.k0 = 16; |
| 236 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 237 | else if ((k % 8) == 0) |
Gian Marco Iodice | 3394f3e | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 238 | { |
| 239 | desc.k0 = 8; |
| 240 | } |
| 241 | else |
| 242 | { |
| 243 | desc.k0 = 4; |
| 244 | } |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 245 | } |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | return desc; |
| 251 | } |
| 252 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 253 | DirectConvComputeKernelInfo ClDirectConvDefaultConfigValhall::configure_G78_u8(const ITensorInfo *src, |
| 254 | const ITensorInfo *wei, |
| 255 | const PadStrideInfo &conv_info) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 256 | { |
| 257 | DirectConvComputeKernelInfo desc; |
| 258 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 259 | if (src->data_layout() == DataLayout::NHWC) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 260 | { |
| 261 | // Get the output shape |
| 262 | TensorShape output_shape = misc::shape_calculator::compute_deep_convolution_shape(*src, *wei, conv_info); |
| 263 | |
| 264 | desc.n0 = 4; |
| 265 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 266 | if (output_shape[0] > 16) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 267 | { |
| 268 | desc.m0 = 4; |
| 269 | } |
| 270 | |
| 271 | desc.k0 = 16; |
| 272 | |
| 273 | desc.export_weights_to_cl_image = false; |
| 274 | } |
| 275 | |
| 276 | return desc; |
| 277 | } |
| 278 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 279 | DirectConvComputeKernelInfo ClDirectConvDefaultConfigValhall::configure_G57_f32(const ITensorInfo *src, |
| 280 | const ITensorInfo *wei, |
| 281 | const PadStrideInfo &conv_info) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 282 | { |
| 283 | DirectConvComputeKernelInfo desc; |
| 284 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 285 | if (src->data_layout() == DataLayout::NHWC) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 286 | { |
| 287 | // Get the output shape |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 288 | const TensorShape wei_shape = wei->tensor_shape(); |
| 289 | const TensorShape dst_shape = misc::shape_calculator::compute_deep_convolution_shape(*src, *wei, conv_info); |
Gian Marco Iodice | ad9a7ed | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 290 | const bool export_weights_to_cl_image = export_to_cl_image(wei); |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 291 | |
| 292 | const int32_t m = dst_shape[1] * dst_shape[2]; |
| 293 | const bool is_pointwise = (wei_shape[1] == wei_shape[2]) && wei_shape[1] == 1; |
| 294 | |
Gian Marco Iodice | ad9a7ed | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 295 | desc.export_weights_to_cl_image = export_weights_to_cl_image; |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 296 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 297 | if (dst_shape[0] <= 4) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 298 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 299 | if (is_pointwise) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 300 | { |
| 301 | desc.m0 = 1; |
| 302 | desc.n0 = 1; |
| 303 | desc.k0 = 16; |
| 304 | } |
| 305 | else |
| 306 | { |
| 307 | desc.m0 = 1; |
| 308 | desc.n0 = dst_shape[0]; |
| 309 | desc.k0 = 16; |
| 310 | } |
| 311 | } |
| 312 | else |
| 313 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 314 | if (m < 64) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 315 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 316 | if (m == 1) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 317 | { |
| 318 | desc.m0 = 1; |
| 319 | desc.n0 = 1; |
| 320 | desc.k0 = 16; |
| 321 | } |
| 322 | else |
| 323 | { |
| 324 | desc.m0 = 4; |
| 325 | desc.n0 = 2; |
| 326 | desc.k0 = 8; |
| 327 | } |
| 328 | } |
| 329 | else |
| 330 | { |
| 331 | desc.m0 = 4; |
| 332 | desc.n0 = 4; |
| 333 | desc.k0 = 4; |
| 334 | } |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | return desc; |
| 339 | } |
| 340 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 341 | DirectConvComputeKernelInfo ClDirectConvDefaultConfigValhall::configure_G57_f16(const ITensorInfo *src, |
| 342 | const ITensorInfo *wei, |
| 343 | const PadStrideInfo &conv_info) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 344 | { |
| 345 | DirectConvComputeKernelInfo desc; |
| 346 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 347 | if (src->data_layout() == DataLayout::NHWC) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 348 | { |
| 349 | // Get the output shape |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 350 | const TensorShape wei_shape = wei->tensor_shape(); |
| 351 | const TensorShape dst_shape = misc::shape_calculator::compute_deep_convolution_shape(*src, *wei, conv_info); |
Gian Marco Iodice | ad9a7ed | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 352 | const bool export_weights_to_cl_image = export_to_cl_image(wei); |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 353 | |
| 354 | const int32_t ofm = dst_shape[0]; |
| 355 | const int32_t m = dst_shape[1] * dst_shape[2]; |
| 356 | const bool is_pointwise = (wei_shape[1] == wei_shape[2]) && wei_shape[1] == 1; |
| 357 | |
Gian Marco Iodice | ad9a7ed | 2022-09-16 14:14:21 +0100 | [diff] [blame] | 358 | desc.export_weights_to_cl_image = export_weights_to_cl_image; |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 359 | |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 360 | if (dst_shape[0] <= 4) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 361 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 362 | if (is_pointwise) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 363 | { |
| 364 | desc.m0 = 2; |
| 365 | desc.n0 = 1; |
| 366 | desc.k0 = 16; |
| 367 | } |
| 368 | else |
| 369 | { |
| 370 | desc.m0 = 1; |
| 371 | desc.n0 = dst_shape[0]; |
| 372 | desc.k0 = 16; |
| 373 | } |
| 374 | } |
| 375 | else |
| 376 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 377 | if (m < 64) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 378 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 379 | if (m == 1) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 380 | { |
| 381 | desc.m0 = 1; |
| 382 | desc.n0 = 1; |
| 383 | desc.k0 = 16; |
| 384 | } |
| 385 | else |
| 386 | { |
| 387 | desc.m0 = 4; |
| 388 | desc.n0 = 2; |
| 389 | desc.k0 = 8; |
| 390 | } |
| 391 | } |
| 392 | else |
| 393 | { |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 394 | if (ofm > 16) |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 395 | { |
| 396 | desc.m0 = 4; |
| 397 | desc.n0 = 8; |
| 398 | desc.k0 = 8; |
| 399 | } |
| 400 | else |
| 401 | { |
| 402 | desc.m0 = 8; |
| 403 | desc.n0 = 4; |
| 404 | desc.k0 = 4; |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | return desc; |
| 411 | } |
Felix Thomasmathibalan | afd38f0 | 2023-09-27 17:46:17 +0100 | [diff] [blame] | 412 | } // namespace cl_direct_conv |
Gian Marco Iodice | 2cc50b3 | 2022-05-30 14:41:49 +0100 | [diff] [blame] | 413 | } // namespace arm_compute |