blob: 98b1488a9d0071fa51bc6549df5da4af9210a430 [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;
44
45namespace
46{
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000047Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
Giorgio Arena0f170392018-07-18 16:13:12 +010048 bool has_bias, const Size2D &dilation, unsigned int num_groups, bool is_fully_connected, bool is_flatten)
Georgios Pinitasd912fd82017-11-27 21:00:13 +000049{
Anthony Barbiereaefd002018-07-20 17:49:35 +010050 ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(input);
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010051 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 +000052 ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() == DataType::QASYMM8 && has_bias);
Alex Gilday7da29b62018-03-23 14:16:00 +000053 ARM_COMPUTE_RETURN_ERROR_ON((dilation.x() < 1) || (dilation.y() < 1));
Giorgio Arena0f170392018-07-18 16:13:12 +010054 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 +000055
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010056 if(output->total_size() > 0)
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000057 {
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010058 TensorShape expected_output_shape;
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000059
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010060 if(is_flatten || is_fully_connected)
61 {
62 expected_output_shape = misc::shape_calculator::compute_flatten_shape(input);
63 }
64 else
65 {
66 expected_output_shape = misc::shape_calculator::compute_im2col_conv_shape(input, kernel_dims, conv_info, has_bias, dilation, false);
67 }
Georgios Pinitasd912fd82017-11-27 21:00:13 +000068
Gian Marco Iodice215b4ea2018-06-28 16:29:29 +010069 TensorInfo expected_output = output->clone()->set_tensor_shape(expected_output_shape);
70 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&expected_output, output);
71 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
72 }
Giorgio Arena156fcf32018-03-09 15:30:43 +000073
Georgios Pinitas631c41a2017-12-06 11:53:03 +000074 return Status{};
Georgios Pinitasd912fd82017-11-27 21:00:13 +000075}
76
Anthony Barbier6ff3b192017-09-04 18:44:23 +010077template <typename T, bool has_pads>
78inline void linearize_volume(const uint8_t *const in_ptr,
79 T *out_ptr,
80 bool has_bias,
81 int top_left_x,
82 int top_left_y,
Gian Marco Iodice13edbff2017-06-26 17:20:16 +010083 int kernel_width,
84 int kernel_height,
Anthony Barbier6ff3b192017-09-04 18:44:23 +010085 int kernel_depth,
86 int input_w,
87 int input_h,
88 int input_stride_x,
89 int input_stride_y,
90 int input_stride_z,
Alex Gilday7da29b62018-03-23 14:16:00 +000091 int pad_value,
92 int dilation_x,
93 int dilation_y)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010094{
Gian Marco Iodice13edbff2017-06-26 17:20:16 +010095 const int kernel_size2 = kernel_width * kernel_height;
Alex Gilday7da29b62018-03-23 14:16:00 +000096 const int x_e = top_left_x + kernel_width * dilation_x;
97 const int y_e = top_left_y + kernel_height * dilation_y;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010098
99 // Linearize volume
100 int d = 0;
101 // This for loop linearize a volume with 3 slices. This allows:
102 // 1) to reduce the iterations of the outer for loop "d"
103 // 2) to have an optimized im2col for the first convolution layer where usually we have 3 IFMs
104 for(; d <= (kernel_depth - 3); d += 3)
105 {
Alex Gilday7da29b62018-03-23 14:16:00 +0000106 for(int y = top_left_y; y < y_e; y += dilation_y)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100107 {
108 if((y < 0 || y >= input_h) && has_pads)
109 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000110 // All the values will be the offset (will be zeros when not quantized)
Alex Gilday7da29b62018-03-23 14:16:00 +0000111 for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100112 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000113 *(out_ptr + 0 * kernel_size2) = pad_value;
114 *(out_ptr + 1 * kernel_size2) = pad_value;
115 *(out_ptr + 2 * kernel_size2) = pad_value;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100116 }
117 }
118 else
119 {
Alex Gilday7da29b62018-03-23 14:16:00 +0000120 for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100121 {
122 if((x < 0 || x >= input_w) && has_pads)
123 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000124 *(out_ptr + 0 * kernel_size2) = pad_value;
125 *(out_ptr + 1 * kernel_size2) = pad_value;
126 *(out_ptr + 2 * kernel_size2) = pad_value;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100127 }
128 else
129 {
130 *(out_ptr + 0 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 0) * input_stride_z + y * input_stride_y + x * input_stride_x)));
131 *(out_ptr + 1 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 1) * input_stride_z + y * input_stride_y + x * input_stride_x)));
132 *(out_ptr + 2 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 2) * input_stride_z + y * input_stride_y + x * input_stride_x)));
133 }
134 }
135 }
136 }
137 out_ptr += 2 * kernel_size2;
138 }
139
140 // Left over
141 for(; d < kernel_depth; d++)
142 {
Alex Gilday7da29b62018-03-23 14:16:00 +0000143 for(int y = top_left_y; y < y_e; y += dilation_y)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100144 {
145 if((y < 0 || y >= input_h) && has_pads)
146 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000147 // All the values will be the offset (will be zeros when not quantized)
148 memset(out_ptr, pad_value, kernel_width * sizeof(T));
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100149 out_ptr += kernel_width;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100150 }
151 else
152 {
Alex Gilday7da29b62018-03-23 14:16:00 +0000153 for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100154 {
155 if((x < 0 || x >= input_w) && has_pads)
156 {
Isabella Gottardie6630e42018-01-18 15:50:39 +0000157 *out_ptr = pad_value;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100158 }
159 else
160 {
161 *out_ptr = *(reinterpret_cast<const T *>(in_ptr + (d * input_stride_z + y * input_stride_y + x * input_stride_x)));
162 }
163 }
164 }
165 }
166 }
167
168 // Append 1 if the convolution layer has biases
169 if(has_bias)
170 {
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100171 *out_ptr = static_cast<T>(1);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100172 }
173}
174} // namespace
175
176template <typename T, bool has_pads>
177void NEIm2ColKernel::run_generic(const Window &window)
178{
179 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
180 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
181
Giorgio Arena156fcf32018-03-09 15:30:43 +0000182 const DataLayout data_layout = _input->info()->data_layout();
183 const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
184 const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
185 const unsigned int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
186
187 const int kernel_depth = _input->info()->dimension(channel_idx);
188 const int input_w = _input->info()->dimension(width_idx);
189 const int input_h = _input->info()->dimension(height_idx);
190 const int input_stride_x = _input->info()->strides_in_bytes()[width_idx];
191 const int input_stride_y = _input->info()->strides_in_bytes()[height_idx];
192 const int input_stride_z = _input->info()->strides_in_bytes()[channel_idx];
Isabella Gottardie6630e42018-01-18 15:50:39 +0000193 const int offset = is_data_type_quantized(_input->info()->data_type()) ? _input->info()->quantization_info().offset : 0;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100194
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100195 int pad_left = 0;
196 int pad_top = 0;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100197 int stride_x = 0;
198 int stride_y = 0;
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100199 pad_left = _conv_info.pad_left();
200 pad_top = _conv_info.pad_top();
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100201 std::tie(stride_x, stride_y) = _conv_info.stride();
202
203 // Setup input window
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100204 const int start_x = -pad_left;
205 const int start_y = -pad_top;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100206
Giorgio Arenaf485a102018-04-20 16:06:21 +0100207 Window window_in_out(window);
208 // The first three dimensions of the input and output are increased by the inner loops
209 window_in_out.set(Window::DimX, Window::Dimension(0, 0, 0));
210 window_in_out.set(Window::DimY, Window::Dimension(0, 0, 0));
211 window_in_out.set(Window::DimZ, Window::Dimension(0, 0, 0));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100212
213 // Create iterators
Giorgio Arenaf485a102018-04-20 16:06:21 +0100214 Iterator in(_input, window_in_out);
215 Iterator out(_output, window_in_out);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100216
217 execute_window_loop(window, [&](const Coordinates & id)
218 {
Giorgio Arena156fcf32018-03-09 15:30:43 +0000219 const int top_left_x = id[width_idx] * stride_x + start_x;
220 const int top_left_y = id[height_idx] * stride_y + start_y;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100221
222 // Get pointers
223 const uint8_t *const input_ptr = in.ptr();
Giorgio Arenaf485a102018-04-20 16:06:21 +0100224 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 +0100225
226 // Linearize volume
227 linearize_volume<T, has_pads>(input_ptr,
228 output_ptr,
229 _has_bias,
230 top_left_x,
231 top_left_y,
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100232 static_cast<int>(_kernel_width),
233 static_cast<int>(_kernel_height),
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100234 kernel_depth,
235 input_w,
236 input_h,
237 input_stride_x,
238 input_stride_y,
239 input_stride_z,
Alex Gilday7da29b62018-03-23 14:16:00 +0000240 offset,
241 _dilation.x(),
242 _dilation.y());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100243 },
244 in, out);
245}
246
247template <typename T>
248void NEIm2ColKernel::run_reduced(const Window &window)
249{
250 const size_t in_width = _input->info()->dimension(0);
251 const size_t in_height = _input->info()->dimension(1);
252 const size_t out_step_x = in_width * _input->info()->element_size();
253 const size_t out_step_y = out_step_x * in_height;
254 const size_t out_width = _output->info()->dimension(0);
255
256 Window in_window(window);
257 in_window.set(Window::DimX, Window::Dimension(0, 1, 1));
258
259 Window out_window;
SiCong Li86b53332017-08-23 11:02:43 +0100260 out_window.use_tensor_dimensions(_output->info()->tensor_shape());
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100261 out_window.set(Window::DimX, Window::Dimension(out_window.x().start(), out_window.x().end(), in_width));
262
263 Window in_slice = in_window.first_slice_window_3D();
264 Window out_slice = out_window.first_slice_window_1D();
265
266 do
267 {
268 Iterator in(_input, in_slice);
269 Iterator out(_output, out_slice);
270
271 uint8_t *out_ptr = out.ptr();
272
273 execute_window_loop(in_slice, [&](const Coordinates & id)
274 {
275 memcpy(out_ptr + id.y() * out_step_x + id.z() * out_step_y, in.ptr(), out_step_x);
276 },
277 in);
278
279 // Add bias
280 if(_has_bias)
281 {
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +0100282 *(reinterpret_cast<T *>(out_ptr) + out_width - 1) = static_cast<T>(1);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100283 }
284 }
285 while(in_window.slide_window_slice_3D(in_slice) && out_window.slide_window_slice_1D(out_slice));
286}
287
288NEIm2ColKernel::NEIm2ColKernel()
Alex Gilday7da29b62018-03-23 14:16:00 +0000289 : _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 +0100290{
291}
292
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +0000293void NEIm2ColKernel::configure(const ITensor *input, ITensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
Giorgio Arena0f170392018-07-18 16:13:12 +0100294 bool has_bias, const Size2D &dilation, unsigned int num_groups, bool is_fully_connected, bool is_flatten)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100295{
Georgios Pinitasd912fd82017-11-27 21:00:13 +0000296 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
297
298 // Perform validation step
Georgios Pinitasd8734b52017-12-22 15:27:52 +0000299 ARM_COMPUTE_UNUSED(is_fully_connected, is_flatten);
Giorgio Arena0f170392018-07-18 16:13:12 +0100300 ARM_COMPUTE_UNUSED(num_groups);
301 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), kernel_dims, conv_info, has_bias, dilation, num_groups, is_fully_connected, is_flatten));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100302
Giorgio Arena156fcf32018-03-09 15:30:43 +0000303 const DataLayout data_layout = input->info()->data_layout();
304 const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
305 const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
306 const unsigned int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
307
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100308 _input = input;
309 _output = output;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100310 _conv_info = conv_info;
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100311 _kernel_width = kernel_dims.width;
Alex Gilday7da29b62018-03-23 14:16:00 +0000312 _kernel_height = kernel_dims.height;
313 _dilation = dilation;
Giorgio Arena156fcf32018-03-09 15:30:43 +0000314 _convolved_dims = scaled_dimensions(input->info()->dimension(width_idx), input->info()->dimension(height_idx),
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100315 _kernel_width, _kernel_height,
Alex Gilday7da29b62018-03-23 14:16:00 +0000316 _conv_info, _dilation);
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100317 _has_bias = has_bias;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100318
Moritz Pflanzer484e7b32017-08-09 11:43:18 +0100319 unsigned int stride_x = 0;
320 unsigned int stride_y = 0;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100321 std::tie(stride_x, stride_y) = conv_info.stride();
322
323 bool run_img2col_reduced = (output->info()->dimension(0) == (input->info()->dimension(0) * input->info()->dimension(1) * input->info()->dimension(2))) && (TensorShape::num_max_dimensions >= 4)
324 && (std::equal(input->info()->tensor_shape().cbegin() + 3,
325 input->info()->tensor_shape().cend(),
326 output->info()->tensor_shape().cbegin() + 1))
Alex Gilday7da29b62018-03-23 14:16:00 +0000327 && ((stride_x == 1) && (stride_y == 1) && !conv_info.has_padding())
328 && ((dilation.x() == 1) && (dilation.y() == 1));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100329
330 Window window = calculate_max_window(*input->info(), Steps());
331
332 if(run_img2col_reduced)
333 {
334 switch(_input->info()->data_type())
335 {
336 case DataType::F32:
337 _func = &NEIm2ColKernel::run_reduced<float>;
338 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000339#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Pablo Tello659abc02017-06-22 16:00:16 +0100340 case DataType::F16:
341 _func = &NEIm2ColKernel::run_reduced<float16_t>;
342 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000343#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Isabella Gottardie6630e42018-01-18 15:50:39 +0000344 case DataType::QASYMM8:
345 _func = &NEIm2ColKernel::run_reduced<qasymm8_t>;
346 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100347 default:
348 ARM_COMPUTE_ERROR("Data type not supported");
349 break;
350 }
351 }
352 else
353 {
354 switch(_input->info()->data_type())
355 {
356 case DataType::F32:
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100357 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<float, false> : &NEIm2ColKernel::run_generic<float, true>;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100358 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000359#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Pablo Tello659abc02017-06-22 16:00:16 +0100360 case DataType::F16:
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100361 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<float16_t, false> : &NEIm2ColKernel::run_generic<float16_t, true>;
Pablo Tello659abc02017-06-22 16:00:16 +0100362 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000363#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Isabella Gottardie6630e42018-01-18 15:50:39 +0000364 case DataType::QASYMM8:
365 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<qasymm8_t, false> : &NEIm2ColKernel::run_generic<qasymm8_t, true>;
366 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100367 default:
368 ARM_COMPUTE_ERROR("Data type not supported");
369 break;
370 }
Giorgio Arena156fcf32018-03-09 15:30:43 +0000371 window.set(width_idx, Window::Dimension(0, _convolved_dims.first, 1));
372 window.set(height_idx, Window::Dimension(0, _convolved_dims.second, 1));
373 window.set(channel_idx, Window::Dimension(0, 1, 1));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100374 }
375
376 // The NEIm2ColKernel doesn't need padding so update_window_and_padding() can be skipped
377 output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape()));
378
379 IKernel::configure(window);
380}
381
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +0000382Status NEIm2ColKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
Giorgio Arena0f170392018-07-18 16:13:12 +0100383 bool has_bias, const Size2D &dilation, unsigned int num_groups, bool is_fully_connected, bool is_flatten)
Georgios Pinitasd912fd82017-11-27 21:00:13 +0000384{
Giorgio Arena0f170392018-07-18 16:13:12 +0100385 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, kernel_dims, conv_info, has_bias, dilation, num_groups, is_fully_connected, is_flatten));
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000386 return Status{};
Georgios Pinitasd912fd82017-11-27 21:00:13 +0000387}
388
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100389void NEIm2ColKernel::run(const Window &window, const ThreadInfo &info)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100390{
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100391 ARM_COMPUTE_UNUSED(info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100392 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
393 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
394
395 (this->*_func)(window);
396}