blob: 325e4b994c223358a0d20ebdea0f258ece742310 [file] [log] [blame]
Michalis Spyrou04f089c2017-08-08 17:42:38 +01001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2020 Arm Limited.
Michalis Spyrou04f089c2017-08-08 17:42:38 +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 */
24#include "arm_compute/core/CL/kernels/CLReductionOperationKernel.h"
25
Michalis Spyrou04f089c2017-08-08 17:42:38 +010026#include "arm_compute/core/CL/CLHelpers.h"
27#include "arm_compute/core/CL/CLKernelLibrary.h"
28#include "arm_compute/core/CL/ICLTensor.h"
Michalis Spyrou04f089c2017-08-08 17:42:38 +010029#include "arm_compute/core/Helpers.h"
30#include "arm_compute/core/TensorInfo.h"
31#include "arm_compute/core/Utils.h"
32#include "arm_compute/core/Validate.h"
Sang-Hoon Park2697fd82019-10-15 16:49:24 +010033#include "arm_compute/core/utils/misc/ShapeCalculator.h"
Sang-Hoon Park68dd25f2020-10-19 16:00:11 +010034#include "src/core/AccessWindowStatic.h"
35#include "src/core/CL/CLValidate.h"
36#include "src/core/helpers/AutoConfiguration.h"
37#include "src/core/helpers/WindowHelpers.h"
Michalis Spyrou04f089c2017-08-08 17:42:38 +010038
Matthew Bentham758b5ba2020-03-05 23:37:48 +000039#include "support/StringSupport.h"
Michalis Spyrou04f089c2017-08-08 17:42:38 +010040
Michele Di Giorgio9637b2e2019-09-23 16:49:49 +010041namespace arm_compute
42{
John Richardson62385bc2018-04-20 13:11:36 +010043namespace
44{
Manuel Bottini34f88dd2019-10-18 10:37:46 +000045// OpenCL kernel requires input width to be a power of 2 for x-axis.
46constexpr unsigned int border_val = 64;
Michalis Spyrou25747e22018-08-08 17:12:38 +010047
Michalis Spyrou7e9391b2018-10-05 14:49:28 +010048Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op, unsigned int width)
John Richardson62385bc2018-04-20 13:11:36 +010049{
John Richardson62385bc2018-04-20 13:11:36 +010050 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, output);
Georgios Pinitas8f5802f2019-02-22 11:08:32 +000051 ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(input);
Georgios Pinitas8be91482019-03-26 17:23:28 +000052 if(input->num_channels() == 1)
53 {
Michalis Spyrou0b18d972020-01-30 18:11:13 +000054 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QASYMM8, DataType::QASYMM8_SIGNED, DataType::S32, DataType::F16, DataType::F32);
Georgios Pinitas8be91482019-03-26 17:23:28 +000055 }
56 else
57 {
58 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 2, DataType::F32);
59 }
Michalis Spyrou8aaf93e2018-10-11 17:33:32 +010060 ARM_COMPUTE_RETURN_ERROR_ON_MSG(op == ReductionOperation::SUM_SQUARE && input->data_type() == DataType::QASYMM8, "Not supported reduction operation for QASYMM8");
John Richardson62385bc2018-04-20 13:11:36 +010061 ARM_COMPUTE_RETURN_ERROR_ON_MSG(axis >= TensorShape::num_max_dimensions, "Reduction axis greater than max number of dimensions");
Michalis Spyrou7e9391b2018-10-05 14:49:28 +010062 ARM_COMPUTE_RETURN_ERROR_ON_MSG(axis > 3, "Unsupported reduction axis");
Michalis Spyrou0b18d972020-01-30 18:11:13 +000063 ARM_COMPUTE_RETURN_ERROR_ON((op == ReductionOperation::MEAN_SUM) && (axis == 0) && (width == 0) && (input->data_type() != DataType::QASYMM8) && (input->data_type() != DataType::QASYMM8_SIGNED));
64 ARM_COMPUTE_RETURN_ERROR_ON_MSG((op == ReductionOperation::ARG_IDX_MAX) || (op == ReductionOperation::ARG_IDX_MIN), "Not supported reduction operation, use CLArgMinMaxLayer");
John Richardson62385bc2018-04-20 13:11:36 +010065
66 if(output->total_size() != 0)
67 {
Manuel Bottini7b9998d2019-10-21 17:59:07 +010068 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
69 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(input, output);
John Richardson62385bc2018-04-20 13:11:36 +010070 }
71
72 return Status{};
73}
74
Michalis Spyrou7930db42018-11-22 17:36:28 +000075std::tuple<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, unsigned int axis, ReductionOperation op)
John Richardson62385bc2018-04-20 13:11:36 +010076{
77 // Output tensor auto initialization if not yet initialized
Manuel Bottini7b9998d2019-10-21 17:59:07 +010078 const TensorShape output_shape = arm_compute::misc::shape_calculator::compute_reduced_shape(input->tensor_shape(), axis, true);
79 DataType output_data_type = input->data_type();
Georgios Pinitas8be91482019-03-26 17:23:28 +000080 auto_init_if_empty(*output, input->clone()->set_tensor_shape(output_shape).set_data_type(output_data_type).reset_padding().set_is_resizable(true));
John Richardson62385bc2018-04-20 13:11:36 +010081
Michalis Spyrou7e9391b2018-10-05 14:49:28 +010082 const unsigned int num_elems_processed_per_iteration = (is_data_type_quantized(input->data_type()) && (axis == 0)) ? 1 : 16;
83 Window win = calculate_max_window(*input, Steps(num_elems_processed_per_iteration));
84 bool window_changed = false;
Sang-Hoon Park2697fd82019-10-15 16:49:24 +010085 const bool is_serial_op = needs_serialized_reduction(op, input->data_type(), axis);
John Richardson62385bc2018-04-20 13:11:36 +010086
Michalis Spyrou7e9391b2018-10-05 14:49:28 +010087 switch(axis)
88 {
89 case 0:
90 {
Michele Di Giorgio03337042020-02-26 17:47:55 +000091 if(!is_serial_op)
Michalis Spyrou7e9391b2018-10-05 14:49:28 +010092 {
Manuel Bottini34f88dd2019-10-18 10:37:46 +000093 const unsigned int border_width = ((input->dimension(0) % border_val) != 0) ? border_val - input->dimension(0) % border_val : 0;
Michalis Spyrou7e9391b2018-10-05 14:49:28 +010094 AccessWindowStatic input_access(input, 0, 0, input->dimension(0) + border_width, 1);
95 AccessWindowHorizontal output_access(output, 0, 1);
96 window_changed = update_window_and_padding(win, input_access, output_access);
97 output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape()));
98 }
99 }
100 break;
101 case 1:
102 case 2:
103 case 3:
104 {
105 AccessWindowHorizontal input_access(input, 0, num_elems_processed_per_iteration);
106 AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration);
107 window_changed = update_window_and_padding(win, input_access, output_access);
108 output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape()));
109 }
110 break;
111 default:
112 ARM_COMPUTE_ERROR("Not supported");
113 }
John Richardson62385bc2018-04-20 13:11:36 +0100114
115 Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{};
116
117 return std::make_tuple(err, win);
118}
119} // namespace
120
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100121CLReductionOperationKernel::CLReductionOperationKernel()
122 : _input(nullptr), _output(nullptr), _reduction_axis(0), _op(ReductionOperation::SUM_SQUARE), _border_size()
123{
124}
125
126BorderSize CLReductionOperationKernel::border_size() const
127{
128 return _border_size;
129}
130
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100131void CLReductionOperationKernel::configure(const ICLTensor *input, ICLTensor *output, unsigned int axis, ReductionOperation op, unsigned int width)
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100132{
Manuel Bottini4c6bd512020-04-08 10:15:51 +0100133 configure(CLKernelLibrary::get().get_compile_context(), input, output, axis, op, width);
134}
135
Manuel Bottini2803f702020-04-21 16:20:03 +0100136void CLReductionOperationKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, unsigned int axis, ReductionOperation op, unsigned int width)
Manuel Bottini4c6bd512020-04-08 10:15:51 +0100137{
John Richardson62385bc2018-04-20 13:11:36 +0100138 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100139
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100140 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), axis, op, width));
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100141
142 _input = input;
143 _output = output;
144 _reduction_axis = axis;
145 _op = op;
Michalis Spyrou343722b2018-06-05 13:04:40 +0100146
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100147 // Set build options
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100148 CLBuildOptions build_opts;
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000149 DataType data_type = input->info()->data_type();
150 std::string data_type_promoted{};
151
152 if(is_data_type_quantized(data_type))
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100153 {
Michalis Spyrou9bd49f92020-02-07 15:25:17 +0000154 data_type_promoted = "int";
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000155 }
156 else
157 {
158 data_type_promoted = get_cl_type_from_data_type(data_type);
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100159 }
Michalis Spyroub9626ab2019-05-13 17:41:01 +0100160
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000161 build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type));
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100162 build_opts.add_option("-DDATA_TYPE_PROMOTED=" + data_type_promoted);
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000163 build_opts.add_option_if(is_data_type_float(data_type), "-DFLOAT_DATA_TYPE");
Manuel Bottinib412fab2018-12-10 17:40:23 +0000164 build_opts.add_option_if(op == ReductionOperation::SUM_SQUARE, "-DSUM_SQUARE");
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100165 build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DMEAN");
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000166 build_opts.add_option_if(op == ReductionOperation::SUM, "-DSUM");
Manuel Bottinib412fab2018-12-10 17:40:23 +0000167 build_opts.add_option_if(op == ReductionOperation::PROD, "-DPROD");
Usama Arifb2890502019-05-21 11:48:37 +0100168 build_opts.add_option_if(op == ReductionOperation::MIN, "-DMIN");
Usama Arif048b0f32019-05-22 16:32:27 +0100169 build_opts.add_option_if(op == ReductionOperation::MAX, "-DMAX");
Georgios Pinitas8be91482019-03-26 17:23:28 +0000170 build_opts.add_option_if(input->info()->num_channels() == 2, "-DCOMPLEX");
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000171 build_opts.add_option_if(is_data_type_quantized(data_type), "-DOFFSET=" + support::cpp11::to_string(input->info()->quantization_info().uniform().offset));
172 build_opts.add_option_if(is_data_type_quantized(data_type), "-DSCALE=" + float_to_string_with_full_precision(input->info()->quantization_info().uniform().scale));
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100173
174 switch(op)
175 {
176 case ReductionOperation::SUM_SQUARE:
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100177 build_opts.add_option(("-DOPERATION=square_sum"));
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100178 break;
179 case ReductionOperation::SUM:
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100180 case ReductionOperation::MEAN_SUM:
181 build_opts.add_option(("-DOPERATION=sum"));
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100182 break;
Usama Arifb2890502019-05-21 11:48:37 +0100183 case ReductionOperation::MIN:
Usama Arif048b0f32019-05-22 16:32:27 +0100184 case ReductionOperation::MAX:
Michalis Spyrou7930db42018-11-22 17:36:28 +0000185 break;
Manuel Bottinib412fab2018-12-10 17:40:23 +0000186 case ReductionOperation::PROD:
187 build_opts.add_option(("-DOPERATION=product"));
188 break;
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100189 default:
190 ARM_COMPUTE_ERROR("Unsupported reduction operation");
191 }
192
193 // Create kernel
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100194 cl::NDRange lws_hint = CLKernelLibrary::get().default_ndrange();
195 std::string kernel_axis_name;
Sang-Hoon Park2697fd82019-10-15 16:49:24 +0100196 const bool is_serial_op = needs_serialized_reduction(_op, _input->info()->data_type(), _reduction_axis);
197
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100198 switch(axis)
199 {
200 case 0:
201 {
Manuel Bottinib412fab2018-12-10 17:40:23 +0000202 if(is_serial_op)
203 {
204 build_opts.add_option("-DWIDTH=" + support::cpp11::to_string(input->info()->dimension(0)));
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000205 build_opts.add_option_if_else(_input->info()->data_type() == DataType::F16, "-DCOND_DATA_TYPE=short", "-DCOND_DATA_TYPE=int");
Manuel Bottinib412fab2018-12-10 17:40:23 +0000206 kernel_axis_name = "non_parallel_x";
207 }
208 else
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100209 {
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000210 build_opts.add_option_if(op == ReductionOperation::MEAN_SUM, "-DWIDTH=" + support::cpp11::to_string(width));
211 const unsigned int width_leftover = input->info()->dimension(0) % border_val;
212 const unsigned int border_width = (width_leftover != 0) ? border_val - width_leftover : 0;
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000213 kernel_axis_name = "x";
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100214
Manuel Bottini7b9998d2019-10-21 17:59:07 +0100215 lws_hint = create_lws_hint_parallel_implementations(input->info()->dimension(0), border_val);
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000216 _border_size = BorderSize(0, border_width, 0, 0);
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100217 }
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100218 }
219 break;
220 case 1:
221 build_opts.add_option("-DHEIGHT=" + support::cpp11::to_string(input->info()->dimension(1)));
222 kernel_axis_name = "y";
223 break;
224 case 2:
225 build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
226 kernel_axis_name = "z";
227 break;
228 case 3:
229 build_opts.add_option("-DDEPTH=" + support::cpp11::to_string(input->info()->dimension(2)));
230 build_opts.add_option("-DBATCH=" + support::cpp11::to_string(input->info()->dimension(3)));
231 kernel_axis_name = "w";
232 break;
233 default:
234 ARM_COMPUTE_ERROR("Not supported");
235 }
Manuel Bottini4c6bd512020-04-08 10:15:51 +0100236 _kernel = create_kernel(compile_context, "reduction_operation_" + kernel_axis_name, build_opts.options());
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100237
238 // Configure kernel window
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000239 auto win_config = validate_and_configure_window(_input->info(), _output->info(), axis, op);
240
241 ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
242
Anthony Barbierb6eb3532018-08-08 13:20:04 +0100243 ICLKernel::configure_internal(std::get<1>(win_config), lws_hint);
John Richardson62385bc2018-04-20 13:11:36 +0100244}
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100245
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100246Status CLReductionOperationKernel::validate(const ITensorInfo *input, const ITensorInfo *output, unsigned int axis, ReductionOperation op, unsigned int width)
John Richardson62385bc2018-04-20 13:11:36 +0100247{
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100248 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, axis, op, width));
Michalis Spyrou7930db42018-11-22 17:36:28 +0000249 ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), axis, op)));
John Richardson62385bc2018-04-20 13:11:36 +0100250
251 return Status{};
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100252}
253
254void CLReductionOperationKernel::run(const Window &window, cl::CommandQueue &queue)
255{
256 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
257 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(IKernel::window(), window);
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000258
Sang-Hoon Park2697fd82019-10-15 16:49:24 +0100259 const bool is_serial_op = needs_serialized_reduction(_op, _input->info()->data_type(), _reduction_axis);
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100260 switch(_reduction_axis)
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100261 {
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100262 case 0:
263 {
264 // We use parallel reduction only in non quantized types
Manuel Bottinib412fab2018-12-10 17:40:23 +0000265 if(is_serial_op)
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100266 {
267 // Get first input and output slices
268 Window window_in{ window };
269 window_in.set(Window::DimX, Window::Dimension(0, _input->info()->dimension(0), _input->info()->dimension(0)));
270
Michele Di Giorgio03337042020-02-26 17:47:55 +0000271 Window out_window{ window };
272 out_window.set(Window::DimX, Window::Dimension(0, 0, 0));
273
274 Window in_slice = window_in.first_slice_window_1D();
275 Window out_slice = out_window.first_slice_window_1D();
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100276
277 do
278 {
279 unsigned int idx = 0;
280 add_1D_tensor_argument(idx, _input, in_slice);
281 add_1D_tensor_argument(idx, _output, out_slice);
Georgios Pinitas275f99c2019-08-23 12:44:11 +0100282 enqueue(queue, *this, in_slice, lws_hint());
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100283 }
Michele Di Giorgio03337042020-02-26 17:47:55 +0000284 while(window_in.slide_window_slice_1D(in_slice) && out_window.slide_window_slice_1D(out_slice));
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100285 }
Manuel Bottinib412fab2018-12-10 17:40:23 +0000286 else
287 {
288 // Set out window
289 Window out_window(window);
290 out_window.set(Window::DimX, Window::Dimension(0, 0, 0));
291
292 // Get first input and output slices
293 Window in_slice = window.first_slice_window_2D();
294 Window out_slice = out_window.first_slice_window_2D();
295
296 // Reshape window
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000297 const unsigned int border_width = ((in_slice.x().end() % border_val) != 0) ? border_val - in_slice.x().end() % border_val : 0;
Manuel Bottinib412fab2018-12-10 17:40:23 +0000298 in_slice.set(Window::DimX, Window::Dimension(in_slice.x().start(), in_slice.x().end() + border_width, in_slice.x().step()));
299
300 // Set local sums buffer
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000301 unsigned int local_res_size = lws_hint()[0] * _input->info()->element_size();
Manuel Bottinib412fab2018-12-10 17:40:23 +0000302 _kernel.setArg(num_arguments_per_2D_tensor() * 2, local_res_size, nullptr);
303
304 do
305 {
306 unsigned int idx = 0;
307 add_2D_tensor_argument(idx, _input, in_slice);
308 add_2D_tensor_argument(idx, _output, out_slice);
309 enqueue(queue, *this, in_slice, lws_hint());
310 }
311 while(window.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
312 }
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100313 }
314 break;
315 case 1:
316 {
317 // Get first input and output slices
318 Window window_in{ window };
319 window_in.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), _input->info()->dimension(1)));
320 Window in_slice = window_in.first_slice_window_2D();
321 Window out_slice = window.first_slice_window_2D();
322
323 do
324 {
325 unsigned int idx = 0;
326 add_2D_tensor_argument(idx, _input, in_slice);
327 add_2D_tensor_argument(idx, _output, out_slice);
Georgios Pinitas275f99c2019-08-23 12:44:11 +0100328 enqueue(queue, *this, in_slice, lws_hint());
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100329 }
330 while(window_in.slide_window_slice_2D(in_slice) && window.slide_window_slice_2D(out_slice));
331 }
332 break;
333 case 2:
334 {
335 // Get first input and output slices
336 Window window_in{ window };
337 window_in.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), _input->info()->dimension(2)));
338 Window in_slice = window_in.first_slice_window_3D();
339 Window out_slice = window.first_slice_window_3D();
340
341 do
342 {
343 unsigned int idx = 0;
344 add_3D_tensor_argument(idx, _input, in_slice);
345 add_3D_tensor_argument(idx, _output, out_slice);
Georgios Pinitas275f99c2019-08-23 12:44:11 +0100346 enqueue(queue, *this, in_slice, lws_hint());
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100347 }
348 while(window_in.slide_window_slice_3D(in_slice) && window.slide_window_slice_3D(out_slice));
349 }
350 break;
351 case 3:
352 {
353 // Get first input and output slices
354 Window window_in{ window };
355 window_in.set(3, Window::Dimension(0, 1, 1));
356 Window in_slice = window_in.first_slice_window_4D();
357 Window out_slice = window.first_slice_window_4D();
358
359 do
360 {
361 unsigned int idx = 0;
362 add_4D_tensor_argument(idx, _input, in_slice);
363 add_4D_tensor_argument(idx, _output, out_slice);
Georgios Pinitas275f99c2019-08-23 12:44:11 +0100364 enqueue(queue, *this, in_slice, lws_hint());
Michalis Spyrou7e9391b2018-10-05 14:49:28 +0100365 }
366 while(window_in.slide_window_slice_4D(in_slice) && window.slide_window_slice_4D(out_slice));
367 }
368 break;
369 default:
370 ARM_COMPUTE_ERROR("Not supported");
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100371 }
Michalis Spyrou04f089c2017-08-08 17:42:38 +0100372}
Manuel Bottini34f88dd2019-10-18 10:37:46 +0000373} // namespace arm_compute