blob: f03bc49ed3be0a4721f748223083500b27fe5853 [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
26#include "arm_compute/core/Error.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010027#include "arm_compute/core/Helpers.h"
28#include "arm_compute/core/ITensor.h"
Gian Marco Iodice13edbff2017-06-26 17:20:16 +010029#include "arm_compute/core/Size2D.h"
Anthony Barbier6ff3b192017-09-04 18:44:23 +010030#include "arm_compute/core/TensorInfo.h"
31#include "arm_compute/core/Types.h"
32#include "arm_compute/core/Validate.h"
33
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000034#include "arm_compute/core/utils/misc/ShapeCalculator.h"
35
Anthony Barbier6ff3b192017-09-04 18:44:23 +010036#include <arm_neon.h>
37#include <cstddef>
38#include <cstdint>
39#include <cstring>
40#include <tuple>
41
42using namespace arm_compute;
43
44namespace
45{
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000046Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
Alex Gilday7da29b62018-03-23 14:16:00 +000047 bool has_bias, bool is_fully_connected, bool is_flatten, const Size2D &dilation)
Georgios Pinitasd912fd82017-11-27 21:00:13 +000048{
Vidhya Sudhan Loganathan7485d5a2018-07-04 09:34:00 +010049 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 +000050 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
Georgios Pinitasd912fd82017-11-27 21:00:13 +000051 ARM_COMPUTE_RETURN_ERROR_ON(input->data_type() == DataType::QASYMM8 && has_bias);
Alex Gilday7da29b62018-03-23 14:16:00 +000052 ARM_COMPUTE_RETURN_ERROR_ON((dilation.x() < 1) || (dilation.y() < 1));
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000053
Giorgio Arena156fcf32018-03-09 15:30:43 +000054 TensorShape expected_output_shape;
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000055 if(is_flatten) /* Called by FlattenLayer */
56 {
Giorgio Arena156fcf32018-03-09 15:30:43 +000057 expected_output_shape = misc::shape_calculator::compute_im2col_flatten_shape(input);
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000058 }
59 else if(!is_fully_connected) /* Called by ConvolutionLayer */
60 {
Giorgio Arena156fcf32018-03-09 15:30:43 +000061 expected_output_shape = misc::shape_calculator::compute_im2col_conv_shape(input, kernel_dims, conv_info, has_bias, dilation);
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000062 }
63 else /* Called by FullyConnectedLayer */
64 {
65 const int num_batch_dimensions = std::max(0, static_cast<int>(output->tensor_shape().num_dimensions()) - 1);
66 const int num_input_dimensions = input->tensor_shape().num_dimensions() - num_batch_dimensions;
67
Giorgio Arena156fcf32018-03-09 15:30:43 +000068 expected_output_shape = misc::shape_calculator::compute_im2col_fc_shape(input, num_input_dimensions);
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +000069 }
Georgios Pinitasd912fd82017-11-27 21:00:13 +000070
Giorgio Arena156fcf32018-03-09 15:30:43 +000071 TensorInfo expected_output = output->clone()->set_tensor_shape(expected_output_shape);
72 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&expected_output, output);
73
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,
Alex Gilday7da29b62018-03-23 14:16:00 +0000294 bool has_bias, bool is_fully_connected, bool is_flatten, const Size2D &dilation)
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);
Alex Gilday7da29b62018-03-23 14:16:00 +0000300 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), kernel_dims, conv_info, has_bias, is_fully_connected, is_flatten, dilation));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100301
Giorgio Arena156fcf32018-03-09 15:30:43 +0000302 const DataLayout data_layout = input->info()->data_layout();
303 const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
304 const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
305 const unsigned int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
306
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100307 _input = input;
308 _output = output;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100309 _conv_info = conv_info;
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100310 _kernel_width = kernel_dims.width;
Alex Gilday7da29b62018-03-23 14:16:00 +0000311 _kernel_height = kernel_dims.height;
312 _dilation = dilation;
Giorgio Arena156fcf32018-03-09 15:30:43 +0000313 _convolved_dims = scaled_dimensions(input->info()->dimension(width_idx), input->info()->dimension(height_idx),
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100314 _kernel_width, _kernel_height,
Alex Gilday7da29b62018-03-23 14:16:00 +0000315 _conv_info, _dilation);
Gian Marco Iodice13edbff2017-06-26 17:20:16 +0100316 _has_bias = has_bias;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100317
Moritz Pflanzer484e7b32017-08-09 11:43:18 +0100318 unsigned int stride_x = 0;
319 unsigned int stride_y = 0;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100320 std::tie(stride_x, stride_y) = conv_info.stride();
321
322 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)
323 && (std::equal(input->info()->tensor_shape().cbegin() + 3,
324 input->info()->tensor_shape().cend(),
325 output->info()->tensor_shape().cbegin() + 1))
Alex Gilday7da29b62018-03-23 14:16:00 +0000326 && ((stride_x == 1) && (stride_y == 1) && !conv_info.has_padding())
327 && ((dilation.x() == 1) && (dilation.y() == 1));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100328
329 Window window = calculate_max_window(*input->info(), Steps());
330
331 if(run_img2col_reduced)
332 {
333 switch(_input->info()->data_type())
334 {
335 case DataType::F32:
336 _func = &NEIm2ColKernel::run_reduced<float>;
337 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000338#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Pablo Tello659abc02017-06-22 16:00:16 +0100339 case DataType::F16:
340 _func = &NEIm2ColKernel::run_reduced<float16_t>;
341 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000342#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Isabella Gottardie6630e42018-01-18 15:50:39 +0000343 case DataType::QASYMM8:
344 _func = &NEIm2ColKernel::run_reduced<qasymm8_t>;
345 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100346 default:
347 ARM_COMPUTE_ERROR("Data type not supported");
348 break;
349 }
350 }
351 else
352 {
353 switch(_input->info()->data_type())
354 {
355 case DataType::F32:
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100356 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<float, false> : &NEIm2ColKernel::run_generic<float, true>;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100357 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000358#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
Pablo Tello659abc02017-06-22 16:00:16 +0100359 case DataType::F16:
Jaroslaw Rzepeckia1ed41f2017-10-13 11:13:58 +0100360 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<float16_t, false> : &NEIm2ColKernel::run_generic<float16_t, true>;
Pablo Tello659abc02017-06-22 16:00:16 +0100361 break;
Ioan-Cristian Szabo5edbd1c2017-11-13 13:34:08 +0000362#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Isabella Gottardie6630e42018-01-18 15:50:39 +0000363 case DataType::QASYMM8:
364 _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_generic<qasymm8_t, false> : &NEIm2ColKernel::run_generic<qasymm8_t, true>;
365 break;
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100366 default:
367 ARM_COMPUTE_ERROR("Data type not supported");
368 break;
369 }
Giorgio Arena156fcf32018-03-09 15:30:43 +0000370 window.set(width_idx, Window::Dimension(0, _convolved_dims.first, 1));
371 window.set(height_idx, Window::Dimension(0, _convolved_dims.second, 1));
372 window.set(channel_idx, Window::Dimension(0, 1, 1));
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100373 }
374
375 // The NEIm2ColKernel doesn't need padding so update_window_and_padding() can be skipped
376 output->info()->set_valid_region(ValidRegion(Coordinates(), output->info()->tensor_shape()));
377
378 IKernel::configure(window);
379}
380
Ioan-Cristian Szabob4e3e1c2017-11-30 17:17:17 +0000381Status NEIm2ColKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
Alex Gilday7da29b62018-03-23 14:16:00 +0000382 bool has_bias, bool is_fully_connected, bool is_flatten, const Size2D &dilation)
Georgios Pinitasd912fd82017-11-27 21:00:13 +0000383{
Alex Gilday7da29b62018-03-23 14:16:00 +0000384 ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, kernel_dims, conv_info, has_bias, is_fully_connected, is_flatten, dilation));
Georgios Pinitas631c41a2017-12-06 11:53:03 +0000385 return Status{};
Georgios Pinitasd912fd82017-11-27 21:00:13 +0000386}
387
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100388void NEIm2ColKernel::run(const Window &window, const ThreadInfo &info)
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100389{
Moritz Pflanzerc186b572017-09-07 09:48:04 +0100390 ARM_COMPUTE_UNUSED(info);
Anthony Barbier6ff3b192017-09-04 18:44:23 +0100391 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
392 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(INEKernel::window(), window);
393
394 (this->*_func)(window);
395}