blob: 18d648d2f24594cc0cacaeaa887c3002308047f0 [file] [log] [blame]
steniu0127b386c2017-07-18 17:37:43 +01001/*
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +00002 * Copyright (c) 2017-2021 Arm Limited.
steniu0127b386c2017-07-18 17:37:43 +01003 *
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 */
Sheri Zhang1efed922021-03-10 22:43:38 +000024#include "src/core/gpu/cl/kernels/ClDirectConvolutionKernel.h"
steniu0127b386c2017-07-18 17:37:43 +010025
steniu0127b386c2017-07-18 17:37:43 +010026#include "arm_compute/core/CL/CLHelpers.h"
27#include "arm_compute/core/CL/CLKernelLibrary.h"
28#include "arm_compute/core/CL/ICLTensor.h"
steniu0127b386c2017-07-18 17:37:43 +010029#include "arm_compute/core/Helpers.h"
steniu0127b386c2017-07-18 17:37:43 +010030#include "arm_compute/core/ITensor.h"
Gian Marco Iodiced95c3e82021-01-19 17:39:02 +000031#include "arm_compute/core/PixelValue.h"
Gian Marco Iodice5cb4d6a2017-08-08 10:53:00 +010032#include "arm_compute/core/Utils.h"
Giorgio Arenac0f54432018-03-16 14:02:34 +000033#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Chunosovd621bca2017-11-03 17:33:15 +070034#include "arm_compute/core/utils/quantization/AsymmHelpers.h"
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010035#include "src/core/AccessWindowStatic.h"
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +010036#include "src/core/CL/CLUtils.h"
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010037#include "src/core/CL/CLValidate.h"
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +010038#include "src/core/CL/gemm/CLGEMMHelpers.h"
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010039#include "src/core/helpers/AutoConfiguration.h"
40#include "src/core/helpers/WindowHelpers.h"
Sheri Zhang1efed922021-03-10 22:43:38 +000041#include "support/Cast.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000042#include "support/StringSupport.h"
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +010043namespace arm_compute
44{
Sheri Zhang1efed922021-03-10 22:43:38 +000045namespace opencl
46{
47namespace kernels
48{
Georgios Pinitas30902ed2017-11-14 15:32:57 +000049namespace
50{
Sheri Zhang1efed922021-03-10 22:43:38 +000051Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const PadStrideInfo &conv_info)
Georgios Pinitas30902ed2017-11-14 15:32:57 +000052{
Sheri Zhang1efed922021-03-10 22:43:38 +000053 ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(src);
54 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(src, 1, DataType::QASYMM8_SIGNED, DataType::QASYMM8, DataType::F16, DataType::F32);
55 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, weights);
Pablo Tello3d319462018-06-21 15:13:17 +010056
Sheri Zhang1efed922021-03-10 22:43:38 +000057 const DataLayout data_layout = src->data_layout();
Pablo Tello3d319462018-06-21 15:13:17 +010058 const int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
59 const int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
60 const int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
61
62 ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->dimension(width_idx) != weights->dimension(height_idx), "Weights should have same width and height");
Sheri Zhang1efed922021-03-10 22:43:38 +000063 ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->dimension(channel_idx) != src->dimension(channel_idx),
64 "Weights feature map dimension should match the respective src's one");
Pablo Tello3d319462018-06-21 15:13:17 +010065 ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->num_dimensions() > 4, "Weights can be at most 4 dimensional");
66 ARM_COMPUTE_RETURN_ERROR_ON_MSG((weights->dimension(width_idx) == 1) && std::get<0>(conv_info.stride()) > 3, "Strides larger than 3 not supported for 1x1 convolution.");
Georgios Pinitasaa95ddc2020-07-21 22:45:13 +010067 ARM_COMPUTE_RETURN_ERROR_ON_MSG((weights->dimension(width_idx) == 3 || weights->dimension(width_idx) == 5 || weights->dimension(width_idx) == 9)
68 && std::get<0>(conv_info.stride()) > 2,
69 "Strides larger than 2 not supported for 3x3, 5x5, 9x9 convolution.");
Georgios Pinitas30902ed2017-11-14 15:32:57 +000070
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +000071 if(data_layout == DataLayout::NCHW)
72 {
Sheri Zhang1efed922021-03-10 22:43:38 +000073 if(is_data_type_quantized(src->data_type()))
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +000074 {
75 ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->dimension(width_idx) != 1 && weights->dimension(width_idx) != 3 && weights->dimension(width_idx) != 5 && weights->dimension(width_idx) != 9,
Gian Marco Iodiced95c3e82021-01-19 17:39:02 +000076 "Kernel sizes other than 1x1, 3x3, 5x5 or 9x9 are not supported with quantized data types");
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +000077 }
78 else
79 {
80 ARM_COMPUTE_RETURN_ERROR_ON_MSG(weights->dimension(width_idx) != 1 && weights->dimension(width_idx) != 3 && weights->dimension(width_idx) != 5,
81 "Kernel sizes other than 1x1, 3x3 or 5x5 are not supported with float data types");
82 }
83 }
84
Georgios Pinitas30902ed2017-11-14 15:32:57 +000085 if(biases != nullptr)
86 {
Sheri Zhang1efed922021-03-10 22:43:38 +000087 if(is_data_type_quantized_asymmetric(src->data_type()))
Georgios Pinitas30902ed2017-11-14 15:32:57 +000088 {
89 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(biases, 1, DataType::S32);
90 }
91 else
92 {
93 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(weights, biases);
94 }
95 ARM_COMPUTE_RETURN_ERROR_ON_MSG(biases->dimension(0) != weights->dimension(3),
Sheri Zhang1efed922021-03-10 22:43:38 +000096 "Biases size and number of src feature maps should match");
Georgios Pinitas30902ed2017-11-14 15:32:57 +000097 ARM_COMPUTE_RETURN_ERROR_ON_MSG(biases->num_dimensions() > 1,
98 "Biases should be one dimensional");
99 }
100
Sheri Zhang1efed922021-03-10 22:43:38 +0000101 // Checks performed when dst is configured
102 if(dst->total_size() != 0)
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000103 {
Sheri Zhang1efed922021-03-10 22:43:38 +0000104 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(dst->tensor_shape(),
105 misc::shape_calculator::compute_deep_convolution_shape(*src, *weights, conv_info));
106 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst);
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000107 }
108
Sheri Zhang1efed922021-03-10 22:43:38 +0000109 const auto data_type = src->data_type();
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100110 if(is_data_type_quantized(data_type))
111 {
Sheri Zhang1efed922021-03-10 22:43:38 +0000112 const UniformQuantizationInfo iqinfo = src->quantization_info().uniform();
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100113 const UniformQuantizationInfo wqinfo = weights->quantization_info().uniform();
Sheri Zhang1efed922021-03-10 22:43:38 +0000114 const UniformQuantizationInfo oqinfo = dst->quantization_info().uniform();
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100115
116 float multiplier = iqinfo.scale * wqinfo.scale / oqinfo.scale;
117 int output_multiplier = 0;
118 int output_shift = 0;
119 ARM_COMPUTE_RETURN_ON_ERROR(quantization::calculate_quantized_multiplier(multiplier, &output_multiplier, &output_shift));
120 }
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000121 return Status{};
Georgios Pinitas30902ed2017-11-14 15:32:57 +0000122}
123
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000124inline bool can_run_optimized_kernel_for_bifrost_nchw(GPUTarget gpu_target, unsigned int conv_stride_x, unsigned int conv_stride_y, unsigned int kernel_size,
125 DataType data_type, DataLayout data_layout)
Giorgio Arena59486342017-12-01 10:42:47 +0000126{
Georgios Pinitasa34286e2018-09-04 12:18:50 +0100127 return gpu_target_is_in(gpu_target,
128 GPUTarget::G71, GPUTarget::G72, GPUTarget::G76,
129 GPUTarget::G51, GPUTarget::G51BIG, GPUTarget::G51LIT,
130 GPUTarget::G52, GPUTarget::G52LIT)
131 && (kernel_size <= 5)
132 && (conv_stride_x == 1) && (conv_stride_y == 1)
133 && (data_type == DataType::F32)
134 && (data_layout == DataLayout::NCHW);
Pablo Tello3d319462018-06-21 15:13:17 +0100135}
Giorgio Arena59486342017-12-01 10:42:47 +0000136
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000137inline void setup_num_elems_nchw(unsigned int &num_elems_read_per_iteration_x, unsigned int &num_elems_read_per_iteration_y,
138 unsigned int &num_elems_written_per_iteration_x, unsigned int &num_elems_written_per_iteration_y,
Sheri Zhang1efed922021-03-10 22:43:38 +0000139 unsigned int kernel_size, const PadStrideInfo &conv_info, const GPUTarget target, ITensorInfo *src)
Pablo Tello3d319462018-06-21 15:13:17 +0100140{
Sheri Zhang1efed922021-03-10 22:43:38 +0000141 const DataType data_type = src->data_type();
142 const DataLayout data_layout = src->data_layout();
Pablo Tello3d319462018-06-21 15:13:17 +0100143 unsigned int conv_stride_x = std::get<0>(conv_info.stride());
144 unsigned int conv_stride_y = std::get<1>(conv_info.stride());
Giorgio Arena59486342017-12-01 10:42:47 +0000145
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000146 const bool run_optimized_bifrost = can_run_optimized_kernel_for_bifrost_nchw(target, conv_stride_x, conv_stride_y, kernel_size, data_type, data_layout);
Giorgio Arena59486342017-12-01 10:42:47 +0000147
Pablo Tello3d319462018-06-21 15:13:17 +0100148 if(run_optimized_bifrost)
Giorgio Arena59486342017-12-01 10:42:47 +0000149 {
150 // Configure kernel window
Giorgio Arena59486342017-12-01 10:42:47 +0000151 switch(kernel_size)
152 {
153 case 1:
154 {
155 num_elems_read_per_iteration_x = 4;
156 num_elems_read_per_iteration_y = 4;
157 num_elems_written_per_iteration_x = 4;
158 num_elems_written_per_iteration_y = 4;
159 break;
160 }
161 case 3:
162 {
163 num_elems_read_per_iteration_x = 6;
164 num_elems_read_per_iteration_y = 5;
165 num_elems_written_per_iteration_x = 4;
166 num_elems_written_per_iteration_y = 3;
167 break;
168 }
169 case 5:
170 {
171 num_elems_read_per_iteration_x = 8;
172 num_elems_read_per_iteration_y = 6;
173 num_elems_written_per_iteration_x = 4;
174 num_elems_written_per_iteration_y = 2;
175 break;
176 }
177 default:
178 {
179 ARM_COMPUTE_ERROR("Kernel size not optimized for Bifrost");
180 }
181 }
182 }
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000183 else
Giorgio Arena59486342017-12-01 10:42:47 +0000184 {
Giorgio Arena59486342017-12-01 10:42:47 +0000185 num_elems_read_per_iteration_y = kernel_size;
186 num_elems_written_per_iteration_x = 8;
187 num_elems_written_per_iteration_y = 1;
Anthony Barbiercc9fed52017-12-13 10:46:00 +0000188 switch(kernel_size)
189 {
190 case 1:
191 switch(conv_stride_x)
192 {
193 case 1:
194 num_elems_read_per_iteration_x = 8;
195 break;
196 case 2:
197 num_elems_read_per_iteration_x = 16;
198 break;
199 case 3:
Sheri Zhang1efed922021-03-10 22:43:38 +0000200 switch(src->element_size())
Anthony Barbiercc9fed52017-12-13 10:46:00 +0000201 {
202 case 1:
203 num_elems_read_per_iteration_x = 28;
204 break;
205 case 2:
206 num_elems_read_per_iteration_x = 24;
207 break;
208 case 4:
209 num_elems_read_per_iteration_x = 22;
210 break;
211 default:
212 ARM_COMPUTE_ERROR("Invalid data size");
213 }
214 break;
215 default:
216 ARM_COMPUTE_ERROR("Invalid convolution stride X");
217 }
218 break;
219 case 3:
220 switch(conv_stride_x)
221 {
222 case 1:
223 num_elems_read_per_iteration_x = 10;
224 break;
225 case 2:
226 num_elems_read_per_iteration_x = 17;
227 break;
228 default:
229 ARM_COMPUTE_ERROR("Invalid convolution stride X");
230 }
231 break;
232 case 5:
233 switch(conv_stride_x)
234 {
235 case 1:
236 num_elems_read_per_iteration_x = 12;
237 break;
238 case 2:
239 num_elems_read_per_iteration_x = 20;
240 break;
241 default:
242 ARM_COMPUTE_ERROR("Invalid convolution stride X");
243 }
244 break;
Sang-Hoon Parkab5b1a22019-10-15 09:29:13 +0100245 case 9:
246 switch(conv_stride_x)
247 {
248 case 1:
249 num_elems_read_per_iteration_x = 16;
250 break;
251 case 2:
252 num_elems_read_per_iteration_x = 24;
253 break;
254 default:
255 ARM_COMPUTE_ERROR("Invalid convolution stride X");
256 }
257 break;
Anthony Barbiercc9fed52017-12-13 10:46:00 +0000258 default:
259 ARM_COMPUTE_ERROR("Invalid direct convolution size");
260 }
Giorgio Arena59486342017-12-01 10:42:47 +0000261 }
Pablo Tello3d319462018-06-21 15:13:17 +0100262}
263
Sheri Zhang1efed922021-03-10 22:43:38 +0000264std::pair<Status, Window> validate_and_configure_window(ITensorInfo *src, ITensorInfo *weights, ITensorInfo *dst, const PadStrideInfo &conv_info, const GPUTarget target)
Pablo Tello3d319462018-06-21 15:13:17 +0100265{
Sheri Zhang1efed922021-03-10 22:43:38 +0000266 const DataLayout data_layout = src->data_layout();
Pablo Tello3d319462018-06-21 15:13:17 +0100267
Sheri Zhang1efed922021-03-10 22:43:38 +0000268 // Get dst shape
269 TensorShape output_shape = misc::shape_calculator::compute_deep_convolution_shape(*src, *weights, conv_info);
Pablo Tello3d319462018-06-21 15:13:17 +0100270
271 // Output auto inizialitation if not yet initialized
Sheri Zhang1efed922021-03-10 22:43:38 +0000272 auto_init_if_empty(*dst, output_shape,
Pablo Tello3d319462018-06-21 15:13:17 +0100273 1,
Sheri Zhang1efed922021-03-10 22:43:38 +0000274 src->data_type(),
275 src->quantization_info());
Pablo Tello3d319462018-06-21 15:13:17 +0100276
Pablo Tello3d319462018-06-21 15:13:17 +0100277 if(data_layout == DataLayout::NHWC)
278 {
Sheri Zhang1efed922021-03-10 22:43:38 +0000279 const unsigned int vec_size = std::min(static_cast<unsigned int>(dst->tensor_shape()[0]), 4u);
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100280 unsigned int num_rows = 1U;
281 if(dst->tensor_shape()[0] > 16)
282 {
283 num_rows = src->data_type() == DataType::F32 ? 2U : 4U;
284 }
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000285
286 // Create window and update padding
Michalis Spyrou702dc0c2021-03-19 15:06:07 +0000287 Window win = calculate_max_window(output_shape, Steps(vec_size, num_rows));
288 return std::make_pair(Status{}, win);
Pablo Tello3d319462018-06-21 15:13:17 +0100289 }
290 else if(data_layout == DataLayout::NCHW)
291 {
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000292 const int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
293 const unsigned int kernel_size = weights->dimension(width_idx);
294
295 unsigned int num_elems_read_per_iteration_x = 0;
296 unsigned int num_elems_read_per_iteration_y = 0;
297 unsigned int num_elems_written_per_iteration_x = 0;
298 unsigned int num_elems_written_per_iteration_y = 0;
299
300 unsigned int conv_pad_left = conv_info.pad_left();
301 unsigned int conv_pad_top = conv_info.pad_top();
302 unsigned int conv_stride_x = std::get<0>(conv_info.stride());
303 unsigned int conv_stride_y = std::get<1>(conv_info.stride());
304
305 setup_num_elems_nchw(num_elems_read_per_iteration_x, num_elems_read_per_iteration_y,
306 num_elems_written_per_iteration_x, num_elems_written_per_iteration_y,
Sheri Zhang1efed922021-03-10 22:43:38 +0000307 kernel_size, conv_info, target, src);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000308
309 // Create window and update padding
310 bool window_changed = false;
Sheri Zhang1efed922021-03-10 22:43:38 +0000311 Window win = calculate_max_window(*dst, Steps(num_elems_written_per_iteration_x, num_elems_written_per_iteration_y));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000312
Sheri Zhang1efed922021-03-10 22:43:38 +0000313 AccessWindowRectangle input_access(src, -conv_pad_left, -conv_pad_top, num_elems_read_per_iteration_x, num_elems_read_per_iteration_y, conv_stride_x, conv_stride_y);
Pablo Tello3d319462018-06-21 15:13:17 +0100314 AccessWindowStatic weights_access(weights, 0, 0, kernel_size, kernel_size);
Sheri Zhang1efed922021-03-10 22:43:38 +0000315 AccessWindowRectangle output_access(dst, 0, 0, num_elems_written_per_iteration_x, num_elems_written_per_iteration_y);
Pablo Tello3d319462018-06-21 15:13:17 +0100316 window_changed = update_window_and_padding(win, input_access, weights_access, output_access);
Sheri Zhang1efed922021-03-10 22:43:38 +0000317 output_access.set_valid_region(win, ValidRegion(Coordinates(), dst->tensor_shape()));
Pablo Tello3d319462018-06-21 15:13:17 +0100318 Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{};
319 return std::make_pair(err, win);
320 }
321 else
322 {
323 ARM_COMPUTE_ERROR("Not supported");
324 }
Giorgio Arena59486342017-12-01 10:42:47 +0000325}
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100326
327bool export_to_cl_image_support(ITensorInfo *tensor, GPUTarget gpu_target, DataLayout data_layout)
328{
329 if(tensor->tensor_shape()[0] % 4 || (data_layout != DataLayout::NHWC))
330 {
331 return false;
332 }
333
334 // If not floating point
335 if(!is_data_type_float(tensor->data_type()))
336 {
337 return false;
338 }
339
340 if(gpu_target == GPUTarget::G71 || get_arch_from_target(gpu_target) == GPUTarget::MIDGARD)
341 {
342 return false;
343 }
344
345 // Check if the cl_khr_image2d_from_buffer extension is supported on the target platform
346 if(!image2d_from_buffer_supported(CLKernelLibrary::get().get_device()))
347 {
348 return false;
349 }
350
351 // Check cl image pitch alignment
352 if(get_cl_image_pitch_alignment(CLKernelLibrary::get().get_device()) == 0)
353 {
354 return false;
355 }
356
357 const size_t image_w = tensor->tensor_shape()[0] / 4;
358 const size_t image_h = tensor->tensor_shape()[1] * tensor->tensor_shape()[2] * tensor->tensor_shape()[3];
359 const size_t max_image_w = CLKernelLibrary::get().get_device().getInfo<CL_DEVICE_IMAGE2D_MAX_WIDTH>();
360 const size_t max_image_h = CLKernelLibrary::get().get_device().getInfo<CL_DEVICE_IMAGE2D_MAX_HEIGHT>();
361
362 if(image_w > max_image_w || image_h > max_image_h)
363 {
364 return false;
365 }
366
367 return true;
368}
369
Giorgio Arena59486342017-12-01 10:42:47 +0000370} // namespace
371
Sheri Zhang1efed922021-03-10 22:43:38 +0000372BorderSize ClDirectConvolutionKernel::border_size() const
Giorgio Arena59486342017-12-01 10:42:47 +0000373{
374 return _border_size;
375}
376
Sheri Zhang1efed922021-03-10 22:43:38 +0000377void ClDirectConvolutionKernel::configure(const CLCompileContext &compile_context, ITensorInfo *src, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *dst,
378 const PadStrideInfo &conv_info)
Giorgio Arena59486342017-12-01 10:42:47 +0000379{
Sheri Zhang1efed922021-03-10 22:43:38 +0000380 ARM_COMPUTE_ERROR_ON_NULLPTR(src, weights, dst);
Giorgio Arena59486342017-12-01 10:42:47 +0000381
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000382 // Perform validation
Sheri Zhang1efed922021-03-10 22:43:38 +0000383 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src,
384 weights,
385 (biases != nullptr) ? biases : nullptr,
386 dst,
Giorgio Arena59486342017-12-01 10:42:47 +0000387 conv_info));
388
Sheri Zhang1efed922021-03-10 22:43:38 +0000389 const int conv_stride_x = std::get<0>(conv_info.stride());
390 const int conv_stride_y = std::get<1>(conv_info.stride());
391
392 _data_layout = src->data_layout();
393 _conv_info = conv_info;
Pablo Tello3d319462018-06-21 15:13:17 +0100394
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000395 const unsigned int width_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
396 const unsigned int height_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
397 const unsigned int channel_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL);
Sheri Zhang1efed922021-03-10 22:43:38 +0000398 const unsigned int kernel_size = weights->dimension(width_idx);
399 const DataType data_type = src->data_type();
Giorgio Arena59486342017-12-01 10:42:47 +0000400
Michalis Spyroua9676112018-02-22 18:07:43 +0000401 const GPUTarget gpu_target = get_target();
Giorgio Arena59486342017-12-01 10:42:47 +0000402
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000403 // Configure kernel window
Sheri Zhang1efed922021-03-10 22:43:38 +0000404 auto win_config = validate_and_configure_window(src, weights, dst, conv_info, gpu_target);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000405 ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
406 ICLKernel::configure_internal(win_config.second);
407
Giorgio Arena59486342017-12-01 10:42:47 +0000408 std::stringstream kernel_name;
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000409 CLBuildOptions build_options;
410
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000411 if(_data_layout == DataLayout::NHWC)
Pablo Tello3d319462018-06-21 15:13:17 +0100412 {
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000413 _border_size = BorderSize();
Giorgio Arena59486342017-12-01 10:42:47 +0000414
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000415 kernel_name << "direct_convolution_nhwc";
Giorgio Arena59486342017-12-01 10:42:47 +0000416
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100417 const unsigned int n0 = win_config.second.x().step();
418 const unsigned int m0 = win_config.second.y().step();
Gian Marco Iodice3bf76b12021-05-17 16:02:13 +0100419 const unsigned int k0 = adjust_vec_size(is_data_type_quantized(data_type)? 16u : 8u, src->dimension(channel_idx));
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100420 const unsigned int partial_store_n0 = dst->dimension(channel_idx) % n0;
421 const unsigned int pad_left = conv_info.pad_left();
422 const unsigned int pad_top = conv_info.pad_top();
423 const bool export_to_cl_image = export_to_cl_image_support(weights, gpu_target, _data_layout);
Gian Marco Iodice5c9eed82021-03-19 11:26:20 +0000424
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100425 // Update the padding for the weights tensor if we can export to cl_image
426 if(export_to_cl_image)
427 {
428 arm_compute::cl_gemm::update_padding_for_cl_image(weights);
429 }
Pablo Tello3d319462018-06-21 15:13:17 +0100430
Sheri Zhang1efed922021-03-10 22:43:38 +0000431 if(biases != nullptr)
Teresa Charlin8d8a1c52021-02-03 17:01:23 +0000432 {
433 build_options.add_option(std::string("-DHAS_BIAS"));
Sheri Zhang1efed922021-03-10 22:43:38 +0000434 build_options.add_option(std::string("-DBIA_DATA_TYPE=" + get_cl_type_from_data_type(biases->data_type())));
Teresa Charlin8d8a1c52021-02-03 17:01:23 +0000435 }
Gian Marco Iodice5c9eed82021-03-19 11:26:20 +0000436
437 build_options.add_option("-cl-fast-relaxed-math");
438 build_options.add_option("-DSRC_TENSOR_TYPE=BUFFER");
Sheri Zhang1efed922021-03-10 22:43:38 +0000439 build_options.add_option("-DSRC_WIDTH=" + support::cpp11::to_string(src->dimension(width_idx)));
440 build_options.add_option("-DSRC_HEIGHT=" + support::cpp11::to_string(src->dimension(height_idx)));
441 build_options.add_option("-DSRC_CHANNELS=" + support::cpp11::to_string(src->dimension(channel_idx)));
442 build_options.add_option("-DSRC_DATA_TYPE=" + get_cl_type_from_data_type(src->data_type()));
Gian Marco Iodice5c9eed82021-03-19 11:26:20 +0000443 build_options.add_option("-DDST_TENSOR_TYPE=BUFFER");
Sheri Zhang1efed922021-03-10 22:43:38 +0000444 build_options.add_option("-DDST_WIDTH=" + support::cpp11::to_string(dst->dimension(width_idx)));
445 build_options.add_option("-DDST_HEIGHT=" + support::cpp11::to_string(dst->dimension(height_idx)));
446 build_options.add_option("-DDST_CHANNELS=" + support::cpp11::to_string(dst->dimension(channel_idx)));
447 build_options.add_option("-DDST_DATA_TYPE=" + get_cl_type_from_data_type(dst->data_type()));
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100448 build_options.add_option_if_else(export_to_cl_image, "-DWEI_TENSOR_TYPE=IMAGE", "-DWEI_TENSOR_TYPE=BUFFER");
Sheri Zhang1efed922021-03-10 22:43:38 +0000449 build_options.add_option("-DWEI_WIDTH=" + support::cpp11::to_string(weights->dimension(width_idx)));
450 build_options.add_option("-DWEI_HEIGHT=" + support::cpp11::to_string(weights->dimension(height_idx)));
451 build_options.add_option("-DWEI_DATA_TYPE=" + get_cl_type_from_data_type(weights->data_type()));
452 build_options.add_option("-DSTRIDE_X=" + support::cpp11::to_string(conv_stride_x));
453 build_options.add_option("-DSTRIDE_Y=" + support::cpp11::to_string(conv_stride_y));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000454 build_options.add_option("-DPAD_LEFT=" + support::cpp11::to_string(pad_left));
455 build_options.add_option("-DPAD_TOP=" + support::cpp11::to_string(pad_top));
456 build_options.add_option("-DN0=" + support::cpp11::to_string(n0));
457 build_options.add_option("-DM0=" + support::cpp11::to_string(m0));
458 build_options.add_option("-DK0=" + support::cpp11::to_string(k0));
Gian Marco Iodice5c9eed82021-03-19 11:26:20 +0000459 build_options.add_option("-DPARTIAL_N0=" + support::cpp11::to_string(partial_store_n0));
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100460
461 if(is_data_type_quantized(data_type))
462 {
Sheri Zhang1efed922021-03-10 22:43:38 +0000463 const UniformQuantizationInfo iqinfo = src->quantization_info().uniform();
464 const UniformQuantizationInfo wqinfo = weights->quantization_info().uniform();
465 const UniformQuantizationInfo oqinfo = dst->quantization_info().uniform();
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100466
Sheri Zhang1efed922021-03-10 22:43:38 +0000467 PixelValue zero_value = PixelValue(0, src->data_type(), src->quantization_info());
Gian Marco Iodiced95c3e82021-01-19 17:39:02 +0000468 int zero_value_s32;
469 zero_value.get(zero_value_s32);
470
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100471 float multiplier = iqinfo.scale * wqinfo.scale / oqinfo.scale;
472 int output_multiplier = 0;
473 int output_shift = 0;
474 quantization::calculate_quantized_multiplier(multiplier, &output_multiplier, &output_shift);
Gian Marco Iodiced95c3e82021-01-19 17:39:02 +0000475 build_options.add_option("-DIS_QUANTIZED");
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000476 build_options.add_option("-DDST_MULTIPLIER=" + support::cpp11::to_string(output_multiplier));
477 build_options.add_option("-DDST_SHIFT=" + support::cpp11::to_string(output_shift));
478 build_options.add_option("-DSRC_OFFSET=" + support::cpp11::to_string(-iqinfo.offset));
479 build_options.add_option("-DWEI_OFFSET=" + support::cpp11::to_string(-wqinfo.offset));
480 build_options.add_option("-DDST_OFFSET=" + support::cpp11::to_string(oqinfo.offset));
Gian Marco Iodiced95c3e82021-01-19 17:39:02 +0000481 build_options.add_option("-DZERO_VALUE=" + support::cpp11::to_string(zero_value_s32));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000482 build_options.add_option("-DACC_DATA_TYPE=" + get_cl_type_from_data_type(DataType::S32));
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100483 }
484 else
485 {
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000486 build_options.add_option("-DACC_DATA_TYPE=" + get_cl_type_from_data_type(data_type));
Gian Marco Iodice5c9eed82021-03-19 11:26:20 +0000487 build_options.add_option("-DZERO_VALUE=" + support::cpp11::to_string(0));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000488 build_options.add_option("-DSRC_OFFSET=" + support::cpp11::to_string(0));
489 build_options.add_option("-DWEI_OFFSET=" + support::cpp11::to_string(0));
490 build_options.add_option("-DDST_OFFSET=" + support::cpp11::to_string(0));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000491 }
492 }
493 else
494 {
Sheri Zhang1efed922021-03-10 22:43:38 +0000495 _border_size = BorderSize(src->padding());
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000496
497 kernel_name << "direct_convolution" << kernel_size << "x" << kernel_size;
498
Sheri Zhang1efed922021-03-10 22:43:38 +0000499 build_options.add_option_if(biases != nullptr, std::string("-DHAS_BIAS"));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000500
Sheri Zhang1efed922021-03-10 22:43:38 +0000501 const bool run_optimized_for_bifrost = can_run_optimized_kernel_for_bifrost_nchw(gpu_target, conv_stride_x, conv_stride_y, kernel_size, data_type, _data_layout);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000502
503 if(run_optimized_for_bifrost)
504 {
Sheri Zhang1efed922021-03-10 22:43:38 +0000505 build_options.add_option(std::string("-DWEIGHTS_DEPTH=" + support::cpp11::to_string(weights->dimension(channel_idx))));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000506
507 kernel_name << "_f32_bifrost";
508 }
509 else
510 {
511 build_options.add_option(std::string("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type)));
512 build_options.add_option(std::string("-DDATA_SIZE=" + get_data_size_from_data_type(data_type)));
Sheri Zhang1efed922021-03-10 22:43:38 +0000513 build_options.add_option(std::string("-DWEIGHTS_DEPTH=" + support::cpp11::to_string(weights->dimension(channel_idx))));
514 build_options.add_option(std::string("-DSTRIDE_X=" + support::cpp11::to_string(conv_stride_x)));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000515 build_options.add_option(std::string("-DDATA_TYPE_PROMOTED=" + get_cl_type_from_data_type(data_type)));
516
517 if(is_data_type_quantized(data_type))
518 {
Sheri Zhang1efed922021-03-10 22:43:38 +0000519 const UniformQuantizationInfo iqinfo = src->quantization_info().uniform();
520 const UniformQuantizationInfo wqinfo = weights->quantization_info().uniform();
521 const UniformQuantizationInfo oqinfo = dst->quantization_info().uniform();
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000522
523 float multiplier = iqinfo.scale * wqinfo.scale / oqinfo.scale;
524 int output_multiplier = 0;
525 int output_shift = 0;
526 quantization::calculate_quantized_multiplier(multiplier, &output_multiplier, &output_shift);
527 build_options.add_option("-DOUTPUT_MULTIPLIER=" + support::cpp11::to_string(output_multiplier));
528 build_options.add_option("-DOUTPUT_SHIFT=" + support::cpp11::to_string(output_shift));
529 build_options.add_option("-DKERNEL_SIZE=" + support::cpp11::to_string(kernel_size));
530 build_options.add_option("-DINPUT_OFFSET=" + support::cpp11::to_string(-iqinfo.offset));
531 build_options.add_option("-DWEIGHTS_OFFSET=" + support::cpp11::to_string(-wqinfo.offset));
532 build_options.add_option("-DOUTPUT_OFFSET=" + support::cpp11::to_string(oqinfo.offset));
533
534 kernel_name.str("direct_convolution_quantized");
535 }
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100536 }
Giorgio Arena59486342017-12-01 10:42:47 +0000537 }
538
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000539 _kernel = create_kernel(compile_context, kernel_name.str(), build_options.options());
Giorgio Arena59486342017-12-01 10:42:47 +0000540
Giorgio Arena59486342017-12-01 10:42:47 +0000541 // Set config_id for enabling LWS tuning
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000542 _config_id = kernel_name.str();
543 _config_id += "_";
Giorgio Arena59486342017-12-01 10:42:47 +0000544 _config_id += lower_string(string_from_data_type(data_type));
545 _config_id += "_";
546 _config_id += support::cpp11::to_string(kernel_size);
547 _config_id += "_";
Georgios Pinitas15997872018-02-19 13:58:22 +0000548 _config_id += support::cpp11::to_string(border_size().left);
Giorgio Arena59486342017-12-01 10:42:47 +0000549 _config_id += "_";
Georgios Pinitas15997872018-02-19 13:58:22 +0000550 _config_id += support::cpp11::to_string(border_size().top);
Giorgio Arena59486342017-12-01 10:42:47 +0000551 _config_id += "_";
Georgios Pinitas15997872018-02-19 13:58:22 +0000552 _config_id += support::cpp11::to_string(border_size().right);
Giorgio Arena59486342017-12-01 10:42:47 +0000553 _config_id += "_";
Georgios Pinitas15997872018-02-19 13:58:22 +0000554 _config_id += support::cpp11::to_string(border_size().bottom);
Giorgio Arena59486342017-12-01 10:42:47 +0000555 _config_id += "_";
Sheri Zhang1efed922021-03-10 22:43:38 +0000556 _config_id += support::cpp11::to_string(conv_stride_x);
Giorgio Arena59486342017-12-01 10:42:47 +0000557 _config_id += "_";
Sheri Zhang1efed922021-03-10 22:43:38 +0000558 _config_id += support::cpp11::to_string(conv_stride_y);
Giorgio Arena59486342017-12-01 10:42:47 +0000559 _config_id += "_";
Sheri Zhang1efed922021-03-10 22:43:38 +0000560 _config_id += support::cpp11::to_string(dst->dimension(width_idx));
Giorgio Arena59486342017-12-01 10:42:47 +0000561 _config_id += "_";
Sheri Zhang1efed922021-03-10 22:43:38 +0000562 _config_id += support::cpp11::to_string(dst->dimension(height_idx));
Pablo Tello3d319462018-06-21 15:13:17 +0100563 _config_id += "_";
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000564 _config_id += lower_string(string_from_data_layout(_data_layout));
Giorgio Arena59486342017-12-01 10:42:47 +0000565}
566
Sheri Zhang1efed922021-03-10 22:43:38 +0000567Status ClDirectConvolutionKernel::validate(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *biases, const ITensorInfo *dst, const PadStrideInfo &conv_info,
568 const GPUTarget target)
Giorgio Arena59486342017-12-01 10:42:47 +0000569{
Sheri Zhang1efed922021-03-10 22:43:38 +0000570 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, weights, biases, dst, conv_info));
571 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(src->clone().get(), weights->clone().get(), dst->clone().get(), conv_info, target).first);
Giorgio Arena59486342017-12-01 10:42:47 +0000572
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000573 return Status{};
Giorgio Arena59486342017-12-01 10:42:47 +0000574}
575
Sheri Zhang1efed922021-03-10 22:43:38 +0000576void ClDirectConvolutionKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
steniu0127b386c2017-07-18 17:37:43 +0100577{
578 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
579 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window);
580
581 // Get initial windows
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000582 Window slice = window.first_slice_window_3D();
steniu0127b386c2017-07-18 17:37:43 +0100583
Sheri Zhang1efed922021-03-10 22:43:38 +0000584 const auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_0));
585 const auto weights = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_1));
586 const auto biases = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC_2));
587 auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
588
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000589 if(_data_layout == DataLayout::NHWC)
steniu0127b386c2017-07-18 17:37:43 +0100590 {
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100591 cl::Image2D weights_cl_image;
592
593 const size_t dim_y_collapsed = ceil_to_multiple(dst->info()->dimension(1) * dst->info()->dimension(2), slice.y().step());
594 const bool export_to_cl_image = export_to_cl_image_support(weights->info(), get_target(), _data_layout);
595
Gian Marco Iodice5c9eed82021-03-19 11:26:20 +0000596 slice.set(Window::DimY, Window::Dimension(0, dim_y_collapsed, slice.y().step()));
Sheri Zhang1efed922021-03-10 22:43:38 +0000597 slice.set(Window::DimZ, Window::Dimension(0, dst->info()->dimension(3), 1));
steniu0127b386c2017-07-18 17:37:43 +0100598
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100599 if(export_to_cl_image)
600 {
601 const size_t image_w = weights->info()->dimension(0) / 4;
602 const size_t image_h = weights->info()->dimension(1) * weights->info()->dimension(2) * weights->info()->dimension(3);
603 const TensorShape shape2d(image_w, image_h);
604 const size_t image_row_pitch = weights->info()->strides_in_bytes()[1];
605
606 // Export cl_buffer to cl_image
607 weights_cl_image = create_image2d_from_buffer(CLKernelLibrary::get().context(), weights->cl_buffer(), shape2d, weights->info()->data_type(), image_row_pitch);
608 }
609
steniu0127b386c2017-07-18 17:37:43 +0100610 unsigned int idx = 0;
Gian Marco Iodice5c9eed82021-03-19 11:26:20 +0000611 add_4D_tensor_argument(idx, src, slice);
612 add_4D_tensor_argument(idx, dst, slice);
Gian Marco Iodice0b76f7d2021-04-08 17:20:00 +0100613 if(export_to_cl_image)
614 {
615 _kernel.setArg(idx++, weights_cl_image);
616 }
Gian Marco Iodice5c9eed82021-03-19 11:26:20 +0000617 add_4D_tensor_argument(idx, weights, slice);
Sheri Zhang1efed922021-03-10 22:43:38 +0000618 if(biases != nullptr)
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000619 {
Sheri Zhang1efed922021-03-10 22:43:38 +0000620 add_1D_tensor_argument(idx, biases, slice);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000621 }
Anthony Barbierb6eb3532018-08-08 13:20:04 +0100622 enqueue(queue, *this, slice, lws_hint());
steniu0127b386c2017-07-18 17:37:43 +0100623 }
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000624 else
625 {
626 Window win_in = window;
627
Giorgio Arena9a091802021-02-17 16:04:05 +0000628 win_in.adjust(Window::DimX, -_conv_info.pad_left(), true);
629 win_in.adjust(Window::DimY, -_conv_info.pad_top(), true);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000630
631 const int width_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
632 const int height_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
633
Sheri Zhang1efed922021-03-10 22:43:38 +0000634 const int conv_stride_x = std::get<0>(_conv_info.stride());
635 const int conv_stride_y = std::get<1>(_conv_info.stride());
636
637 win_in.set_dimension_step(width_idx, window[width_idx].step() * conv_stride_x);
638 win_in.set_dimension_step(height_idx, window[height_idx].step() * conv_stride_y);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000639
640 Window slice_in = win_in.first_slice_window_3D();
641 unsigned int idx1 = 2 * num_arguments_per_3D_tensor();
Sheri Zhang1efed922021-03-10 22:43:38 +0000642 add_3D_tensor_argument(idx1, weights, slice);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000643
Sheri Zhang1efed922021-03-10 22:43:38 +0000644 if(biases != nullptr)
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000645 {
646 Window slice_biases;
Sheri Zhang1efed922021-03-10 22:43:38 +0000647 slice_biases.use_tensor_dimensions(biases->info()->tensor_shape());
648 add_1D_tensor_argument(idx1, biases, slice_biases);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000649 }
650
Sheri Zhang1efed922021-03-10 22:43:38 +0000651 _kernel.setArg(idx1++, static_cast<unsigned int>(weights->info()->strides_in_bytes()[3]));
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000652
653 do
654 {
655 unsigned int idx = 0;
Sheri Zhang1efed922021-03-10 22:43:38 +0000656 add_3D_tensor_argument(idx, src, slice_in);
657 add_3D_tensor_argument(idx, dst, slice);
Gian Marco Iodiceff1fe3e2021-01-02 09:58:51 +0000658 enqueue(queue, *this, slice, lws_hint());
659 }
660 while(window.slide_window_slice_3D(slice) && win_in.slide_window_slice_3D(slice_in));
661 }
steniu0127b386c2017-07-18 17:37:43 +0100662}
Sheri Zhang1efed922021-03-10 22:43:38 +0000663} // namespace kernels
664} // namespace opencl
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100665} // namespace arm_compute