blob: 2c51eae4688c2a1c9b5b528fc0cd44535c500687 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001/*
Isabella Gottardie6630e42018-01-18 15:50:39 +00002 * Copyright (c) 2017-2018 ARM Limited.
Anthony Barbier6ff3b192017-09-04 18:44:23 +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/NEON/kernels/NEIm2ColKernel.h"
25
Anthony Barbiereaefd002018-07-20 17:49:35 +010026#include "arm_compute/core/CPP/Validate.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027#include "arm_compute/core/Error.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010028#include "arm_compute/core/Helpers.h"
29#include "arm_compute/core/ITensor.h"
Gian Marco Iodice13edbff2017-06-26 17:20:16 +010030#include "arm_compute/core/Size2D.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010031#include "arm_compute/core/TensorInfo.h"
32#include "arm_compute/core/Types.h"
33#include "arm_compute/core/Validate.h"
34
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000035#include "arm_compute/core/utils/misc/ShapeCalculator.h"
36
Anthony Barbier6ff3b192017-09-04 18:44:23 +010037#include <arm_neon.h>
38#include <cstddef>
39#include <cstdint>
40#include <cstring>
41#include <tuple>
42
43using namespace arm_compute;
Giorgio Arena368e6352018-08-20 15:06:07 +010044using namespace misc::shape_calculator;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010045
46namespace
47{
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000048Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
Giorgio Arena368e6352018-08-20 15:06:07 +010049 bool has_bias, const Size2D &dilation, unsigned int num_groups)
Georgios Pinitasd912fd82017-11-27 21:00:13 +000050{
Anthony Barbiereaefd002018-07-20 17:49:35 +010051 ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input);
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010052 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(input, 1, DataType::QASYMM8, DataType::F16, DataType::F32);
Georgios Pinitasd912fd82017-11-27 21:00:13 +000053 ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() == DataType::QASYMM8 && has_bias);
Alex Gilday7da29b62018-03-23 14:16:00 +000054 ARM_COMPUTE_RETURN_ERROR_ON((dilation.x() < 1) || (dilation.y() < 1));
Giorgio Arena0f170392018-07-18 16:13:12 +010055 ARM_COMPUTE_RETURN_ERROR_ON_MSG(num_groups > 1, "Number of groups greater than one are not supported on NEON");
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000056
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010057 if(output->total_size() > 0)
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000058 {
Giorgio Arena368e6352018-08-20 15:06:07 +010059 TensorInfo expected_output = output->clone()->set_tensor_shape(compute_im2col_conv_shape(input, kernel_dims, conv_info, has_bias, dilation, false));
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010060 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&expected_output, output);
61 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
62 }
Giorgio Arena156fcf32018-03-09 15:30:43 +000063
Georgios Pinitas631c41a2017-12-06 11:53:03 +000064 return Status{};
Georgios Pinitasd912fd82017-11-27 21:00:13 +000065}
66
Giorgio Arena368e6352018-08-20 15:06:07 +010067std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
68 bool has_bias, const Size2D &dilation)
69{
70 const unsigned int width_idx = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::WIDTH);
71 const unsigned int height_idx = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::HEIGHT);
72 const unsigned int channel_idx = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::CHANNEL);
73
74 std::pair<unsigned int, unsigned int> convolved_dims = scaled_dimensions(input->dimension(width_idx), input->dimension(height_idx),
75 kernel_dims.width, kernel_dims.height,
76 conv_info, dilation);
77
78 // Output tensor auto initialization if not yet initialized
79 auto_init_if_empty(*output, input->clone()->set_tensor_shape(compute_im2col_conv_shape(input, kernel_dims, conv_info, has_bias, dilation, false)));
80
81 Window win = calculate_max_window(*input, Steps());
82 win.set(width_idx, Window::Dimension(0, convolved_dims.first, 1));
83 win.set(height_idx, Window::Dimension(0, convolved_dims.second, 1));
84 win.set(channel_idx, Window::Dimension(0, 1, 1));
85
86 // The NEIm2ColKernel doesn't need padding so update_window_and_padding() can be skipped
87 output->set_valid_region(ValidRegion(Coordinates(), output->tensor_shape()));
88
89 return std::make_pair(Status{}, win);
90}
91
Anthony Barbier6ff3b192017-09-04 18:44:23 +010092template <typename T, bool has_pads>
Giorgio Arenafb629082018-08-20 18:03:27 +010093inline void linearize_volume_nchw(const uint8_t *const in_ptr,
94 T *out_ptr,
95 bool has_bias,
96 int top_left_x,
97 int top_left_y,
98 int kernel_width,
99 int kernel_height,
100 int kernel_depth,
101 int input_w,
102 int input_h,
103 int input_stride_x,
104 int input_stride_y,
105 int input_stride_z,
106 int pad_value,
107 int dilation_x,
108 int dilation_y)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100109{
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100110 const int kernel_size2 = kernel_width * kernel_height;
Alex Gilday7da29b62018-03-23 14:16:00 +0000111 const int x_e = top_left_x + kernel_width * dilation_x;
112 const int y_e = top_left_y + kernel_height * dilation_y;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100113
114 // Linearize volume
115 int d = 0;
116 // This for loop linearize a volume with 3 slices. This allows:
117 // 1) to reduce the iterations of the outer for loop "d"
118 // 2) to have an optimized im2col for the first convolution layer where usually we have 3 IFMs
119 for(; d <= (kernel_depth - 3); d += 3)
120 {
Alex Gilday7da29b62018-03-23 14:16:00 +0000121 for(int y = top_left_y; y < y_e; y += dilation_y)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100122 {
123 if((y < 0 || y >= input_h) && has_pads)
124 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000125 // All the values will be the offset (will be zeros when not quantized)
Alex Gilday7da29b62018-03-23 14:16:00 +0000126 for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100127 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000128 *(out_ptr + 0 * kernel_size2) = pad_value;
129 *(out_ptr + 1 * kernel_size2) = pad_value;
130 *(out_ptr + 2 * kernel_size2) = pad_value;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100131 }
132 }
133 else
134 {
Alex Gilday7da29b62018-03-23 14:16:00 +0000135 for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100136 {
137 if((x < 0 || x >= input_w) && has_pads)
138 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000139 *(out_ptr + 0 * kernel_size2) = pad_value;
140 *(out_ptr + 1 * kernel_size2) = pad_value;
141 *(out_ptr + 2 * kernel_size2) = pad_value;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100142 }
143 else
144 {
145 *(out_ptr + 0 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 0) * input_stride_z + y * input_stride_y + x * input_stride_x)));
146 *(out_ptr + 1 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 1) * input_stride_z + y * input_stride_y + x * input_stride_x)));
147 *(out_ptr + 2 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 2) * input_stride_z + y * input_stride_y + x * input_stride_x)));
148 }
149 }
150 }
151 }
152 out_ptr += 2 * kernel_size2;
153 }
154
155 // Left over
156 for(; d < kernel_depth; d++)
157 {
Alex Gilday7da29b62018-03-23 14:16:00 +0000158 for(int y = top_left_y; y < y_e; y += dilation_y)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100159 {
160 if((y < 0 || y >= input_h) && has_pads)
161 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000162 // All the values will be the offset (will be zeros when not quantized)
163 memset(out_ptr, pad_value, kernel_width * sizeof(T));
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100164 out_ptr += kernel_width;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100165 }
166 else
167 {
Alex Gilday7da29b62018-03-23 14:16:00 +0000168 for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100169 {
170 if((x < 0 || x >= input_w) && has_pads)
171 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000172 *out_ptr = pad_value;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100173 }
174 else
175 {
176 *out_ptr = *(reinterpret_cast<const T *>(in_ptr + (d * input_stride_z + y * input_stride_y + x * input_stride_x)));
177 }
178 }
179 }
180 }
181 }
182
183 // Append 1 if the convolution layer has biases
184 if(has_bias)
185 {
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100186 *out_ptr = static_cast<T>(1);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100187 }
188}
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100189
190template <typename T, bool has_pads>
Giorgio Arenafb629082018-08-20 18:03:27 +0100191inline void linearize_volume_nhwc(const uint8_t *const in_ptr,
192 T *out_ptr,
193 bool has_bias,
194 int start_x,
195 int start_y,
196 int kernel_width,
197 int kernel_height,
198 int input_w,
199 int input_h,
200 int input_c,
201 int input_stride_y,
202 int input_stride_z,
203 int pad_value,
204 int dilation_x,
205 int dilation_y)
206{
207 const int end_x = start_x + kernel_width * dilation_x;
208 const int end_y = start_y + kernel_height * dilation_y;
209 const int pad_quant = kernel_width * input_c;
210
211 for(int y = start_y; y < end_y; y += dilation_y)
212 {
213 if(y < 0 || y >= input_h)
214 {
215 memset(out_ptr, pad_value, pad_quant * sizeof(T));
216 out_ptr += pad_quant;
217 }
218 else
219 {
220 for(int x = start_x; x < end_x; x += dilation_x)
221 {
222 if(x < 0 || x >= input_w)
223 {
224 memset(out_ptr, pad_value, input_c * sizeof(T));
225 out_ptr += input_c;
226 }
227 else
228 {
229 memcpy(out_ptr, reinterpret_cast<const T *>(in_ptr + (y * input_stride_z + x * input_stride_y)), input_c * sizeof(T));
230 out_ptr += input_c;
231 }
232 }
233 }
234 }
235
236 // Append 1 if the convolution layer has biases
237 if(has_bias)
238 {
239 *out_ptr = static_cast<T>(1);
240 }
241}
242} // namespace
243
244template <typename T, bool has_pads, bool is_nchw>
Giorgio Arena368e6352018-08-20 15:06:07 +0100245void NEIm2ColKernel::run_im2col(const Window &window)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100246{
247 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
248 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
249
Giorgio Arena156fcf32018-03-09 15:30:43 +0000250 const DataLayout data_layout = _input->info()->data_layout();
251 const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
252 const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
253 const unsigned int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
254
Giorgio Arena156fcf32018-03-09 15:30:43 +0000255 const int input_w = _input->info()->dimension(width_idx);
256 const int input_h = _input->info()->dimension(height_idx);
Giorgio Arenafb629082018-08-20 18:03:27 +0100257 const int input_c = _input->info()->dimension(channel_idx);
258 const int input_stride_x = _input->info()->strides_in_bytes().x();
259 const int input_stride_y = _input->info()->strides_in_bytes().y();
260 const int input_stride_z = _input->info()->strides_in_bytes().z();
261 const int pad_left = _conv_info.pad_left();
262 const int pad_top = _conv_info.pad_top();
263 const int stride_x = _conv_info.stride().first;
264 const int stride_y = _conv_info.stride().second;
265 const int pad_value = is_data_type_quantized(_input->info()->data_type()) ? _input->info()->quantization_info().offset : 0;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100266
Giorgio Arenaf485a102018-04-20 16:06:21 +0100267 Window window_in_out(window);
268 // The first three dimensions of the input and output are increased by the inner loops
269 window_in_out.set(Window::DimX, Window::Dimension(0, 0, 0));
270 window_in_out.set(Window::DimY, Window::Dimension(0, 0, 0));
271 window_in_out.set(Window::DimZ, Window::Dimension(0, 0, 0));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100272
273 // Create iterators
Giorgio Arenaf485a102018-04-20 16:06:21 +0100274 Iterator in(_input, window_in_out);
275 Iterator out(_output, window_in_out);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100276
277 execute_window_loop(window, [&](const Coordinates & id)
278 {
Giorgio Arenafb629082018-08-20 18:03:27 +0100279 const int start_w = id[width_idx] * stride_x - pad_left;
280 const int start_h = id[height_idx] * stride_y - pad_top;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100281
282 // Get pointers
283 const uint8_t *const input_ptr = in.ptr();
Giorgio Arenaf485a102018-04-20 16:06:21 +0100284 auto output_ptr = reinterpret_cast<T *>(out.ptr() + (id[width_idx] + id[height_idx] * _convolved_dims.first) * _output->info()->strides_in_bytes().y());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100285
286 // Linearize volume
Giorgio Arenafb629082018-08-20 18:03:27 +0100287 if(is_nchw)
288 {
289 linearize_volume_nchw<T, has_pads>(input_ptr,
290 output_ptr,
291 _has_bias,
292 start_w,
293 start_h,
294 _kernel_width,
295 _kernel_height,
296 input_c,
297 input_w,
298 input_h,
299 input_stride_x,
300 input_stride_y,
301 input_stride_z,
302 pad_value,
303 _dilation.x(),
304 _dilation.y());
305 }
306 else
307 {
308 linearize_volume_nhwc<T, has_pads>(input_ptr,
309 output_ptr,
310 _has_bias,
311 start_w,
312 start_h,
313 _kernel_width,
314 _kernel_height,
315 input_w,
316 input_h,
317 input_c,
318 input_stride_y,
319 input_stride_z,
320 pad_value,
321 _dilation.x(),
322 _dilation.y());
323 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100324 },
325 in, out);
326}
327
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100328NEIm2ColKernel::NEIm2ColKernel()
Alex Gilday7da29b62018-03-23 14:16:00 +0000329 : _func(), _input(nullptr), _output(nullptr), _convolved_dims(), _conv_info(), _kernel_width(0), _kernel_height(0), _has_bias(false), _dilation(1U, 1U)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100330{
331}
332
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +0000333void NEIm2ColKernel::configure(const ITensor *input, ITensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
Giorgio Arena368e6352018-08-20 15:06:07 +0100334 bool has_bias, const Size2D &dilation, unsigned int num_groups)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100335{
Georgios Pinitasd912fd82017-11-27 21:00:13 +0000336 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
Giorgio Arena368e6352018-08-20 15:06:07 +0100337 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), kernel_dims, conv_info, has_bias, dilation, num_groups));
Giorgio Arena0f170392018-07-18 16:13:12 +0100338 ARM_COMPUTE_UNUSED(num_groups);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100339
Giorgio Arena156fcf32018-03-09 15:30:43 +0000340 const DataLayout data_layout = input->info()->data_layout();
341 const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
342 const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
Giorgio Arena156fcf32018-03-09 15:30:43 +0000343
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100344 _input = input;
345 _output = output;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100346 _conv_info = conv_info;
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100347 _kernel_width = kernel_dims.width;
Alex Gilday7da29b62018-03-23 14:16:00 +0000348 _kernel_height = kernel_dims.height;
349 _dilation = dilation;
Giorgio Arena156fcf32018-03-09 15:30:43 +0000350 _convolved_dims = scaled_dimensions(input->info()->dimension(width_idx), input->info()->dimension(height_idx),
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100351 _kernel_width, _kernel_height,
Alex Gilday7da29b62018-03-23 14:16:00 +0000352 _conv_info, _dilation);
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100353 _has_bias = has_bias;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100354
Giorgio Arenafb629082018-08-20 18:03:27 +0100355 if(data_layout == DataLayout::NCHW)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100356 {
Giorgio Arenafb629082018-08-20 18:03:27 +0100357 switch(_input->info()->data_type())
358 {
359 case DataType::F32:
360 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<float, false, true> : &NEIm2ColKernel::run_im2col<float, true, true>;
361 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000362#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Giorgio Arenafb629082018-08-20 18:03:27 +0100363 case DataType::F16:
364 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<float16_t, false, true> : &NEIm2ColKernel::run_im2col<float16_t, true, true>;
365 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000366#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Giorgio Arenafb629082018-08-20 18:03:27 +0100367 case DataType::QASYMM8:
368 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<qasymm8_t, false, true> : &NEIm2ColKernel::run_im2col<qasymm8_t, true, true>;
369 break;
370 default:
371 ARM_COMPUTE_ERROR("Data type not supported");
372 break;
373 }
374 }
375 else
376 {
377 switch(_input->info()->data_type())
378 {
379 case DataType::F32:
380 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<float, false, false> : &NEIm2ColKernel::run_im2col<float, true, false>;
381 break;
382#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
383 case DataType::F16:
384 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<float16_t, false, false> : &NEIm2ColKernel::run_im2col<float16_t, true, false>;
385 break;
386#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
387 case DataType::QASYMM8:
388 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<qasymm8_t, false, false> : &NEIm2ColKernel::run_im2col<qasymm8_t, true, false>;
389 break;
390 default:
391 ARM_COMPUTE_ERROR("Data type not supported");
392 break;
393 }
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100394 }
395
Giorgio Arena368e6352018-08-20 15:06:07 +0100396 // Configure kernel window
397 auto win_config = validate_and_configure_window(input->info(), output->info(), kernel_dims, conv_info, has_bias, dilation);
398 ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
399 INEKernel::configure(win_config.second);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100400}
401
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +0000402Status NEIm2ColKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
Giorgio Arena368e6352018-08-20 15:06:07 +0100403 bool has_bias, const Size2D &dilation, unsigned int num_groups)
Georgios Pinitasd912fd82017-11-27 21:00:13 +0000404{
Giorgio Arena368e6352018-08-20 15:06:07 +0100405 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, kernel_dims, conv_info, has_bias, dilation, num_groups));
406 ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get(), kernel_dims, conv_info, has_bias, dilation).first);
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000407 return Status{};
Georgios Pinitasd912fd82017-11-27 21:00:13 +0000408}
409
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100410void NEIm2ColKernel::run(const Window &window, const ThreadInfo &info)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100411{
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100412 ARM_COMPUTE_UNUSED(info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100413 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
414 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
415
416 (this->*_func)(window);
417}