blob: fab6c36032144fa05044be5c6cd0fa49ed85e665 [file] [log] [blame]
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00001/*
Gian Marco Iodice905a3c12023-04-14 12:20:58 +01002 * Copyright (c) 2018-2023 Arm Limited.
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +00003 *
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 */
Georgios Pinitas7891a732021-08-20 21:39:25 +010024#include "src/gpu/cl/kernels/ClWinogradInputTransformKernel.h"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000025
26#include "arm_compute/core/CL/CLHelpers.h"
27#include "arm_compute/core/CL/CLKernelLibrary.h"
28#include "arm_compute/core/CL/ICLTensor.h"
29#include "arm_compute/core/CL/OpenCL.h"
30#include "arm_compute/core/Error.h"
31#include "arm_compute/core/Helpers.h"
32#include "arm_compute/core/Types.h"
33#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Matthew Bentham314d3e22023-06-23 10:53:52 +000034#include "arm_compute/core/utils/StringUtils.h"
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010035#include "src/core/AccessWindowStatic.h"
36#include "src/core/CL/CLValidate.h"
37#include "src/core/helpers/AutoConfiguration.h"
38#include "src/core/helpers/WindowHelpers.h"
Manuel Bottinic6f4ec32021-05-18 18:41:56 +010039#include "support/Cast.h"
Matthew Bentham758b5ba2020-03-05 23:37:48 +000040#include "support/StringSupport.h"
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000041
Manuel Bottinic6f4ec32021-05-18 18:41:56 +010042namespace arm_compute
43{
44namespace opencl
45{
46namespace kernels
47{
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000048namespace
49{
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000050Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const WinogradInfo &winograd_info)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000051{
Vidhya Sudhan Loganathan71ecf392018-08-31 16:10:16 +010052 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::F32, DataType::F16);
53 ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input);
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000054
55 const PadStrideInfo conv_info = winograd_info.convolution_info;
56 const Size2D output_tile_size = winograd_info.output_tile_size;
57 const Size2D kernel_size = winograd_info.kernel_size;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000058 ARM_COMPUTE_RETURN_ERROR_ON_MSG(conv_info.stride().first != 1 || conv_info.stride().second != 1, "Winograd input transform only supports unit strides");
Gian Marco Iodicef1c2bf02018-06-13 14:05:54 +010059 ARM_COMPUTE_RETURN_ERROR_ON_MSG(!cl_winograd_convolution_layer_supported(output_tile_size, kernel_size, input->data_layout()), "Winograd input transform not supported");
60
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000061 ARM_COMPUTE_UNUSED(conv_info);
62 ARM_COMPUTE_UNUSED(output_tile_size);
63 ARM_COMPUTE_UNUSED(kernel_size);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000064
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000065 // Validate configured output
66 if(output->total_size() != 0)
67 {
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000068 const TensorShape output_shape = misc::shape_calculator::compute_winograd_input_transform_shape(*input, winograd_info);
Gian Marco Iodiced2fab732018-03-02 11:18:12 +000069
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000070 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), output_shape);
71 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
72 }
73
74 return Status{};
75}
76
Gian Marco Iodice247f52c2018-03-22 11:24:56 +000077std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, const WinogradInfo &winograd_info)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000078{
79 ARM_COMPUTE_UNUSED(output);
80 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +000081
Gian Marco Iodice905a3c12023-04-14 12:20:58 +010082 bool window_changed = false;
83 int num_elems_processed_per_iteration = 1;
84
85 if(input->data_layout() == DataLayout::NHWC)
86 {
87 // In the case of FP16 computation, we can perform more
88 // output feature maps in a single work-item.
89 // From experiments, num_elems_processed_per_iteration = 2 looks good for fp16 to
90 // improve the performance. However, in order to make the implementation simpler,
91 // we set num_elems_processed_per_iteration = 2 only when the OFMs are multiple of 2.
92 // Note: At the moment, only Winograd Input Transform 3x3 can support N0 != 1
93 const DataType dt = input->data_type();
94 const size_t dim0 = input->dimension(0);
95 const size_t k_sz = winograd_info.kernel_size.area();
96 const bool cond = dt == DataType::F16 && ((dim0 % 2) == 0);
97 if(cond)
98 {
99 if(k_sz == 3 || k_sz == 9)
100 {
101 num_elems_processed_per_iteration = 2;
102 }
103 }
104 }
105 Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration));
Giorgio Arenac42f28d2018-04-26 11:33:05 +0100106
107 if(input->data_layout() == DataLayout::NCHW)
108 {
Giorgio Arena149fdf32018-07-04 17:03:33 +0100109 const PadStrideInfo conv_info = winograd_info.convolution_info;
110 const Size2D output_tile_size = winograd_info.output_tile_size;
111 const Size2D kernel_size = winograd_info.kernel_size;
112
113 unsigned int num_elems_read_per_iteration_x = output_tile_size.width + kernel_size.width - 1;
114 unsigned int num_elems_read_per_iteration_y = output_tile_size.height + kernel_size.height - 1;
115
116 AccessWindowRectangle input_access(input, -conv_info.pad_left(), -conv_info.pad_top(), num_elems_read_per_iteration_x, num_elems_read_per_iteration_y);
117 window_changed = update_window_and_padding(win, input_access);
Giorgio Arenac42f28d2018-04-26 11:33:05 +0100118 }
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000119
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000120 Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{};
121 return std::make_pair(err, win);
122}
123} // namespace
124
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100125ClWinogradInputTransformKernel::ClWinogradInputTransformKernel()
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000126{
Giorgio Arena4a95bba2021-06-28 11:00:27 +0100127 _type = CLKernelType::WINOGRAD;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000128}
129
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100130BorderSize ClWinogradInputTransformKernel::border_size() const
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000131{
132 return _border_size;
133}
134
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100135void ClWinogradInputTransformKernel::configure(const ClCompileContext &compile_context, ITensorInfo *src, ITensorInfo *dst, const WinogradInfo &winograd_info)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000136{
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100137 ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
138 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst, winograd_info));
Manuel Bottini4c6bd512020-04-08 10:15:51 +0100139
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100140 auto padding_info = get_padding_info({ src, dst });
SiCong Li04a07062020-11-17 14:09:01 +0000141
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000142 const PadStrideInfo conv_info = winograd_info.convolution_info;
143 const Size2D output_tile_size = winograd_info.output_tile_size;
144 const Size2D kernel_size = winograd_info.kernel_size;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000145
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100146 _data_layout = src->data_layout();
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000147
148 const size_t idx_w = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
149 const size_t idx_h = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
Giorgio Arenac42f28d2018-04-26 11:33:05 +0100150
Gian Marco Iodicef1c2bf02018-06-13 14:05:54 +0100151 // Compute the number of output tiles along the x and y direction of size "output_tile_size"
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100152 const Size2D num_tiles = compute_winograd_convolution_tiles(Size2D(src->dimension(idx_w), src->dimension(idx_h)),
Gian Marco Iodicef1c2bf02018-06-13 14:05:54 +0100153 kernel_size,
154 output_tile_size,
155 conv_info);
156
Gian Marco Iodicef1c2bf02018-06-13 14:05:54 +0100157 _num_tiles_x = num_tiles.width;
158 _num_tiles_y = num_tiles.height;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000159
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100160 const TensorShape output_shape = misc::shape_calculator::compute_winograd_input_transform_shape(*src, winograd_info);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000161
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000162 // Output auto initialization if not yet initialized
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100163 auto_init_if_empty(*dst, src->clone()->set_tensor_shape(output_shape));
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000164
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100165 ARM_COMPUTE_ERROR_ON(_num_tiles_x * _num_tiles_y != static_cast<int>(dst->dimension(1)));
166 const size_t total_batches = src->tensor_shape().total_size_upper(3);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000167
Gian Marco Iodice905a3c12023-04-14 12:20:58 +0100168 // Create window and update padding
169 auto win_config = validate_and_configure_window(src, dst, winograd_info);
170 ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
171 IClKernel::configure_internal(win_config.second, cl::NDRange(1, 1, 8));
172
173 _src_width = src->dimension(idx_w);
174 _src_height = src->dimension(idx_h);
175
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000176 CLBuildOptions build_opts;
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000177 if(_data_layout == DataLayout::NHWC)
Giorgio Arenac42f28d2018-04-26 11:33:05 +0100178 {
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100179 build_opts.add_option("-DNHWC");
Gian Marco Iodice905a3c12023-04-14 12:20:58 +0100180 build_opts.add_option("-DN0=" + support::cpp11::to_string(win_config.second.x().step()));
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100181 build_opts.add_option("-DPAD_LEFT=" + support::cpp11::to_string(conv_info.pad_left()));
182 build_opts.add_option("-DPAD_TOP=" + support::cpp11::to_string(conv_info.pad_top()));
183 build_opts.add_option("-DOUTPUT_TILE_W=" + support::cpp11::to_string(output_tile_size.width));
184 build_opts.add_option("-DOUTPUT_TILE_H=" + support::cpp11::to_string(output_tile_size.height));
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100185 build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(src->data_type()));
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100186 build_opts.add_option_if(winograd_info.kernel_size.height == 1, "-DWINOGRAD_INPUT_TRANSFORM_HORIZONTAL");
187 build_opts.add_option_if(winograd_info.kernel_size.width == 1, "-DWINOGRAD_INPUT_TRANSFORM_VERTICAL");
Gian Marco Iodice905a3c12023-04-14 12:20:58 +0100188 build_opts.add_option_if(total_batches > 1, "-DIS_BATCHED");
Giorgio Arenac42f28d2018-04-26 11:33:05 +0100189 }
Georgios Pinitasc55beee2018-10-23 15:23:23 +0100190 else
191 {
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100192 build_opts.add_option("-DNUM_TILES_X=" + support::cpp11::to_string(_num_tiles_x));
193 build_opts.add_option("-DPAD_LEFT=" + support::cpp11::to_string(conv_info.pad_left()));
194 build_opts.add_option("-DPAD_TOP=" + support::cpp11::to_string(conv_info.pad_top()));
195 build_opts.add_option("-DOUTPUT_TILE_W=" + support::cpp11::to_string(output_tile_size.width));
196 build_opts.add_option("-DOUTPUT_TILE_H=" + support::cpp11::to_string(output_tile_size.height));
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100197 build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(src->data_type()));
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100198 build_opts.add_option_if(winograd_info.kernel_size.height == 1, "-DWINOGRAD_INPUT_TRANSFORM_HORIZONTAL");
199 build_opts.add_option_if(winograd_info.kernel_size.width == 1, "-DWINOGRAD_INPUT_TRANSFORM_VERTICAL");
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100200 build_opts.add_option_if(total_batches > 1, "-DSRC_DEPTH=" + support::cpp11::to_string(src->dimension(2)));
Georgios Pinitasc55beee2018-10-23 15:23:23 +0100201 }
Giorgio Arenac42f28d2018-04-26 11:33:05 +0100202
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000203 // Create kernel
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000204 std::string kernel_name = "winograd_input_transform_" + output_tile_size.to_string() + "_" + kernel_size.to_string();
205
Gian Marco Iodicef1c2bf02018-06-13 14:05:54 +0100206 // Get the maximum dimension from the tile size
207 const unsigned int tile_max_dim = std::max(output_tile_size.width, output_tile_size.height);
208
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000209 // Check optimized kernel if output_dims == 2x2
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000210 if((tile_max_dim == 2) && (_data_layout == DataLayout::NCHW))
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000211 {
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100212 _step_z = (src->dimension(2) % 2) != 0 ? 1 : 2;
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000213 }
214
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000215 // Append stepz and data layout
216 kernel_name += "_stepz";
217 kernel_name += support::cpp11::to_string(_step_z);
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000218 kernel_name += "_" + lower_string(string_from_data_layout(_data_layout));
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000219
ramelg012a86a302022-02-04 20:49:14 +0000220 // A macro guard to compile ONLY the kernel of interest
221 build_opts.add_option("-D" + upper_string(kernel_name));
Manuel Bottini4c6bd512020-04-08 10:15:51 +0100222 _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000223
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100224 _border_size = BorderSize(src->padding());
Giorgio Arena2567adf2020-12-14 10:50:50 +0000225
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100226 ARM_COMPUTE_ERROR_ON((src->data_layout() == DataLayout::NHWC) && has_padding_changed(padding_info));
SiCong Li04a07062020-11-17 14:09:01 +0000227
Gian Marco Iodice247f52c2018-03-22 11:24:56 +0000228 _config_id = kernel_name;
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100229 _config_id += support::cpp11::to_string(src->dimension(0));
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000230 _config_id += "_";
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100231 _config_id += support::cpp11::to_string(src->dimension(1));
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000232 _config_id += "_";
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100233 _config_id += support::cpp11::to_string(src->dimension(2));
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000234 _config_id += "_";
235 _config_id += support::cpp11::to_string(conv_info.pad_left());
236 _config_id += "_";
237 _config_id += support::cpp11::to_string(conv_info.pad_top());
Gian Marco Iodicef1c2bf02018-06-13 14:05:54 +0100238 _config_id += "_";
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000239 _config_id += lower_string(string_from_data_layout(_data_layout));
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000240}
241
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100242Status ClWinogradInputTransformKernel::validate(const ITensorInfo *src, const ITensorInfo *dst, const WinogradInfo &winograd_info)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000243{
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100244 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst);
245 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(src, dst, winograd_info));
246 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(src->clone().get(), dst->clone().get(), winograd_info).first);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000247 return Status{};
248}
249
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100250void ClWinogradInputTransformKernel::run_op(ITensorPack &tensors, const Window &window, cl::CommandQueue &queue)
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000251{
252 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
253 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window);
254
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100255 auto src = utils::cast::polymorphic_downcast<const ICLTensor *>(tensors.get_const_tensor(TensorType::ACL_SRC));
256 auto dst = utils::cast::polymorphic_downcast<ICLTensor *>(tensors.get_tensor(TensorType::ACL_DST));
257
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000258 const size_t idx_w = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
259 const size_t idx_h = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
260 const size_t idx_c = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL);
261 const size_t total_batches = window.shape().total_size_upper(3);
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000262
Georgios Pinitasc55beee2018-10-23 15:23:23 +0100263 // Collapse window
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100264 Window window_collapsed = window.collapse_if_possible(IClKernel::window(), Window::DimZ);
Georgios Pinitasc55beee2018-10-23 15:23:23 +0100265
Georgios Pinitas7fdcfb12020-01-09 16:45:46 +0000266 if(_data_layout == DataLayout::NHWC)
Georgios Pinitasc55beee2018-10-23 15:23:23 +0100267 {
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100268 Window slice = window_collapsed.first_slice_window_3D();
269 slice.set(1, Window::Dimension(0, _num_tiles_x * _num_tiles_y, 1));
270 slice.set(2, Window::Dimension(0, total_batches, 1));
Giorgio Arenac42f28d2018-04-26 11:33:05 +0100271
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000272 unsigned int idx = 0;
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100273 add_4D_tensor_argument(idx, src, slice);
274 add_4D_tensor_argument(idx, dst, slice);
ramelg012a86a302022-02-04 20:49:14 +0000275 _kernel.setArg<cl_uint>(idx++, _src_width);
276 _kernel.setArg<cl_uint>(idx++, _src_height);
277 _kernel.setArg<cl_uint>(idx++, _num_tiles_x);
278 _kernel.setArg<cl_uint>(idx++, _num_tiles_y);
Anthony Barbierb6eb3532018-08-08 13:20:04 +0100279 enqueue(queue, *this, slice, lws_hint());
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000280 }
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100281 else
282 {
283 Window slice = window_collapsed.first_slice_window_3D();
284 slice.set(idx_w, Window::Dimension(0, _num_tiles_x, 1));
285 slice.set(idx_h, Window::Dimension(0, _num_tiles_y, 1));
286
287 ARM_COMPUTE_ERROR_ON(((slice[idx_c].end() - slice[idx_c].start()) % _step_z) != 0);
288 slice.set(idx_c, Window::Dimension(slice[idx_c].start(), slice[idx_c].end(), _step_z));
289
290 unsigned int idx = 2 * num_arguments_per_3D_tensor();
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100291 _kernel.setArg<cl_uint>(idx++, static_cast<unsigned int>(src->info()->strides_in_bytes()[3]));
292 _kernel.setArg<cl_uint>(idx++, static_cast<unsigned int>(dst->info()->strides_in_bytes()[3]));
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100293
294 do
295 {
296 unsigned int idx = 0;
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100297 add_3D_tensor_argument(idx, src, slice);
298 add_3D_tensor_argument(idx, dst, slice);
Gian Marco Iodice534b8892021-04-01 16:17:16 +0100299
300 enqueue(queue, *this, slice, lws_hint());
301 }
302 while(window_collapsed.slide_window_slice_3D(slice));
303 }
Giorgio Arena1f9ca1d2018-03-01 11:13:45 +0000304}
Manuel Bottinic6f4ec32021-05-18 18:41:56 +0100305} // namespace kernels
306} // namespace opencl
ramelg012a86a302022-02-04 20:49:14 +0000307} // namespace arm_compute