Compute Library
 21.02
NEIm2ColKernel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 Arm Limited.
3  *
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  */
25 
26 #include "arm_compute/core/Error.h"
31 #include "arm_compute/core/Types.h"
33 #include "src/core/CPP/Validate.h"
36 
38 
39 #include <arm_neon.h>
40 #include <cstddef>
41 #include <cstdint>
42 #include <cstring>
43 #include <tuple>
44 
45 using namespace arm_compute;
46 using namespace misc::shape_calculator;
47 
48 namespace
49 {
50 Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
51  bool has_bias, const Size2D &dilation, unsigned int num_groups)
52 {
57  ARM_COMPUTE_RETURN_ERROR_ON((dilation.x() < 1) || (dilation.y() < 1));
58  ARM_COMPUTE_RETURN_ERROR_ON_MSG(num_groups > 1, "Number of groups greater than one are not supported on Neon");
59 
60  // Since there's no implicit padding added, check the total input spatial dimensions (with conv paddings) are big enough for the kernel dimensions
61  const unsigned int width_idx = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::WIDTH);
62  const unsigned int height_idx = get_data_layout_dimension_index(input->data_layout(), DataLayoutDimension::HEIGHT);
63  const unsigned total_width = input->dimension(width_idx) + conv_info.pad_left() + conv_info.pad_right();
64  const unsigned total_height = input->dimension(height_idx) + conv_info.pad_top() + conv_info.pad_bottom();
65  ARM_COMPUTE_RETURN_ERROR_ON((total_width < kernel_dims.width) || (total_height < kernel_dims.height));
66 
67  if(output->total_size() > 0)
68  {
69  TensorInfo expected_output = output->clone()->set_tensor_shape(compute_im2col_conv_shape(input, kernel_dims, conv_info, has_bias, dilation, false));
70  ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(&expected_output, output);
73  }
74 
75  return Status{};
76 }
77 
78 std::pair<Status, Window> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
79  bool has_bias, const Size2D &dilation)
80 {
81  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
82 
83  // Output tensor auto initialization if not yet initialized
84  auto_init_if_empty(*output, input->clone()->set_tensor_shape(compute_im2col_conv_shape(input, kernel_dims, conv_info, has_bias, dilation, false)));
85 
86  const DataLayout data_layout = input->data_layout();
87  const unsigned int width_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
88  const unsigned int height_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
89  const unsigned int channel_idx = get_data_layout_dimension_index(data_layout, DataLayoutDimension::CHANNEL);
90 
91  std::pair<unsigned int, unsigned int> convolved_dims = scaled_dimensions(input->dimension(width_idx), input->dimension(height_idx),
92  kernel_dims.width, kernel_dims.height,
93  conv_info, dilation);
94 
95  Window win = calculate_max_window(*input, Steps());
96  win.set(width_idx, Window::Dimension(0, convolved_dims.first, 1));
97  win.set(height_idx, Window::Dimension(0, convolved_dims.second, 1));
98  win.set(channel_idx, Window::Dimension(0, 1, 1));
99 
100  // The NEIm2ColKernel doesn't need padding so update_window_and_padding() can be skipped
101  output->set_valid_region(ValidRegion(Coordinates(), output->tensor_shape()));
102 
103  return std::make_pair(Status{}, win);
104 }
105 
106 template <typename T, bool has_pads>
107 inline void linearize_volume_nchw(const uint8_t *const in_ptr,
108  T *out_ptr,
109  bool has_bias,
110  int top_left_x,
111  int top_left_y,
112  int kernel_width,
113  int kernel_height,
114  int kernel_depth,
115  int input_w,
116  int input_h,
117  int input_stride_x,
118  int input_stride_y,
119  int input_stride_z,
120  int pad_value,
121  int dilation_x,
122  int dilation_y)
123 {
124  const int kernel_size2 = kernel_width * kernel_height;
125  const int x_e = top_left_x + kernel_width * dilation_x;
126  const int y_e = top_left_y + kernel_height * dilation_y;
127 
128  // Linearize volume
129  int d = 0;
130  // This for loop linearize a volume with 3 slices. This allows:
131  // 1) to reduce the iterations of the outer for loop "d"
132  // 2) to have an optimized im2col for the first convolution layer where usually we have 3 IFMs
133  for(; d <= (kernel_depth - 3); d += 3)
134  {
135  for(int y = top_left_y; y < y_e; y += dilation_y)
136  {
137  if((y < 0 || y >= input_h) && has_pads)
138  {
139  // All the values will be the offset (will be zeros when not quantized)
140  for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
141  {
142  *(out_ptr + 0 * kernel_size2) = pad_value;
143  *(out_ptr + 1 * kernel_size2) = pad_value;
144  *(out_ptr + 2 * kernel_size2) = pad_value;
145  }
146  }
147  else
148  {
149  for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
150  {
151  if((x < 0 || x >= input_w) && has_pads)
152  {
153  *(out_ptr + 0 * kernel_size2) = pad_value;
154  *(out_ptr + 1 * kernel_size2) = pad_value;
155  *(out_ptr + 2 * kernel_size2) = pad_value;
156  }
157  else
158  {
159  *(out_ptr + 0 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 0) * input_stride_z + y * input_stride_y + x * input_stride_x)));
160  *(out_ptr + 1 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 1) * input_stride_z + y * input_stride_y + x * input_stride_x)));
161  *(out_ptr + 2 * kernel_size2) = *(reinterpret_cast<const T *>(in_ptr + ((d + 2) * input_stride_z + y * input_stride_y + x * input_stride_x)));
162  }
163  }
164  }
165  }
166  out_ptr += 2 * kernel_size2;
167  }
168 
169  // Left over
170  for(; d < kernel_depth; d++)
171  {
172  for(int y = top_left_y; y < y_e; y += dilation_y)
173  {
174  if((y < 0 || y >= input_h) && has_pads)
175  {
176  // All the values will be the offset (will be zeros when not quantized)
177  memset(static_cast<void *>(out_ptr), pad_value, kernel_width * sizeof(T));
178  out_ptr += kernel_width;
179  }
180  else
181  {
182  for(int x = top_left_x; x < x_e; x += dilation_x, ++out_ptr)
183  {
184  if((x < 0 || x >= input_w) && has_pads)
185  {
186  *out_ptr = pad_value;
187  }
188  else
189  {
190  *out_ptr = *(reinterpret_cast<const T *>(in_ptr + (d * input_stride_z + y * input_stride_y + x * input_stride_x)));
191  }
192  }
193  }
194  }
195  }
196 
197  // Append 1 if the convolution layer has biases
198  if(has_bias)
199  {
200  *out_ptr = static_cast<T>(1);
201  }
202 }
203 
204 template <typename T, bool has_pads>
205 inline void linearize_volume_nhwc(const uint8_t *const in_ptr,
206  T *out_ptr,
207  bool has_bias,
208  int start_x,
209  int start_y,
210  int kernel_width,
211  int kernel_height,
212  int input_w,
213  int input_h,
214  int input_c,
215  int input_stride_y,
216  int input_stride_z,
217  int pad_value,
218  int dilation_x,
219  int dilation_y)
220 {
221  const int end_x = start_x + kernel_width * dilation_x;
222  const int end_y = start_y + kernel_height * dilation_y;
223  const int pad_quant = kernel_width * input_c;
224  const int element_size = static_cast<int>(sizeof(T));
225  if((start_y >= 0) && (end_y < input_h) && (start_x >= 0) && (end_x < input_w) && (dilation_x == 1) && (input_stride_y == input_c * element_size))
226  {
227  for(int y = start_y; y < end_y; y += dilation_y)
228  {
229  //optimized for no dilation and no boundary pixels
230  memcpy(out_ptr, reinterpret_cast<const T *>(in_ptr + (y * input_stride_z + start_x * input_stride_y)), input_c * kernel_width * element_size);
231  out_ptr += input_c * kernel_width;
232  }
233  }
234  else
235  {
236  for(int y = start_y; y < end_y; y += dilation_y)
237  {
238  if(y < 0 || y >= input_h)
239  {
240  memset(static_cast<void *>(out_ptr), pad_value, pad_quant * element_size);
241  out_ptr += pad_quant;
242  }
243  else if(dilation_x > 1 || start_x < 0 || end_x >= input_w || input_stride_y != input_c * element_size)
244  {
245  for(int x = start_x; x < end_x; x += dilation_x)
246  {
247  if(x < 0 || x >= input_w)
248  {
249  memset(static_cast<void *>(out_ptr), pad_value, input_c * element_size);
250  out_ptr += input_c;
251  }
252  else
253  {
254  memcpy(out_ptr, reinterpret_cast<const T *>(in_ptr + (y * input_stride_z + x * input_stride_y)), input_c * element_size);
255  out_ptr += input_c;
256  }
257  }
258  }
259  else
260  {
261  //optimized for no dilation and no boundary pixels
262  memcpy(out_ptr, reinterpret_cast<const T *>(in_ptr + (y * input_stride_z + start_x * input_stride_y)), input_c * kernel_width * element_size);
263  out_ptr += input_c * kernel_width;
264  }
265  }
266  }
267  // Append 1 if the convolution layer has biases
268  if(has_bias)
269  {
270  *out_ptr = static_cast<T>(1);
271  }
272 }
273 } // namespace
274 
275 template <typename T, bool has_pads, bool is_nchw>
276 void NEIm2ColKernel::run_im2col(const Window &window)
277 {
280 
281  const unsigned int width_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
282  const unsigned int height_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
283  const unsigned int channel_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::CHANNEL);
284 
285  const int input_w = _input->info()->dimension(width_idx);
286  const int input_h = _input->info()->dimension(height_idx);
287  const int input_c = _input->info()->dimension(channel_idx);
288  const int input_stride_x = _input->info()->strides_in_bytes().x();
289  const int input_stride_y = _input->info()->strides_in_bytes().y();
290  const int input_stride_z = _input->info()->strides_in_bytes().z();
291  const int pad_left = _conv_info.pad_left();
292  const int pad_top = _conv_info.pad_top();
293  const int stride_x = _conv_info.stride().first;
294  const int stride_y = _conv_info.stride().second;
295  const int pad_value = is_data_type_quantized(_input->info()->data_type()) ? _input->info()->quantization_info().uniform().offset : 0;
296 
297  Window window_in_out(window);
298  // The first three dimensions of the input and output are increased by the inner loops
299  window_in_out.set(Window::DimX, Window::Dimension(0, 0, 0));
300  window_in_out.set(Window::DimY, Window::Dimension(0, 0, 0));
301  window_in_out.set(Window::DimZ, Window::Dimension(0, 0, 0));
302 
303  // Create iterators
304  Iterator in(_input, window_in_out);
305  Iterator out(_output, window_in_out);
306 
307  execute_window_loop(window, [&](const Coordinates & id)
308  {
309  const int start_w = id[width_idx] * stride_x - pad_left;
310  const int start_h = id[height_idx] * stride_y - pad_top;
311 
312  // Get pointers
313  const uint8_t *const input_ptr = in.ptr();
314  auto output_ptr = reinterpret_cast<T *>(out.ptr() + (id[width_idx] + id[height_idx] * _convolved_dims.first) * _output->info()->strides_in_bytes().y());
315 
316  // Linearize volume
317  if(is_nchw)
318  {
319  linearize_volume_nchw<T, has_pads>(input_ptr,
320  output_ptr,
321  _has_bias,
322  start_w,
323  start_h,
324  _kernel_width,
325  _kernel_height,
326  input_c,
327  input_w,
328  input_h,
329  input_stride_x,
332  pad_value,
333  _dilation.x(),
334  _dilation.y());
335  }
336  else
337  {
338  linearize_volume_nhwc<T, has_pads>(input_ptr,
339  output_ptr,
340  _has_bias,
341  start_w,
342  start_h,
343  _kernel_width,
344  _kernel_height,
345  input_w,
346  input_h,
347  input_c,
350  pad_value,
351  _dilation.x(),
352  _dilation.y());
353  }
354  },
355  in, out);
356 }
357 
359  : _func(), _input(nullptr), _output(nullptr), _convolved_dims(), _conv_info(), _kernel_width(0), _kernel_height(0), _has_bias(false), _dilation(1U, 1U), _data_layout(DataLayout::UNKNOWN)
360 {
361 }
362 
363 void NEIm2ColKernel::configure(const ITensor *input, ITensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
364  bool has_bias, const Size2D &dilation, unsigned int num_groups)
365 {
366  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
367  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), kernel_dims, conv_info, has_bias, dilation, num_groups));
368  ARM_COMPUTE_UNUSED(num_groups);
369 
370  _data_layout = input->info()->data_layout();
371  const unsigned int width_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::WIDTH);
372  const unsigned int height_idx = get_data_layout_dimension_index(_data_layout, DataLayoutDimension::HEIGHT);
373 
374  _input = input;
375  _output = output;
376  _conv_info = conv_info;
377  _kernel_width = kernel_dims.width;
378  _kernel_height = kernel_dims.height;
379  _dilation = dilation;
380  _convolved_dims = scaled_dimensions(input->info()->dimension(width_idx), input->info()->dimension(height_idx),
381  _kernel_width, _kernel_height,
382  _conv_info, _dilation);
383  _has_bias = has_bias;
384 
385  if(_data_layout == DataLayout::NCHW)
386  {
387  switch(_input->info()->data_type())
388  {
389  case DataType::F32:
390  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<float, false, true> : &NEIm2ColKernel::run_im2col<float, true, true>;
391  break;
392 #if defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) || defined(ARM_COMPUTE_FORCE_BF16)
393  case DataType::BFLOAT16:
394  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<bfloat16, false, true> : &NEIm2ColKernel::run_im2col<bfloat16, true, true>;
395  break;
396 #endif /* defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) || defined(ARM_COMPUTE_FORCE_BF16) */
397 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
398  case DataType::F16:
399  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<float16_t, false, true> : &NEIm2ColKernel::run_im2col<float16_t, true, true>;
400  break;
401 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
403  case DataType::QASYMM8:
404  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<qasymm8_t, false, true> : &NEIm2ColKernel::run_im2col<qasymm8_t, true, true>;
405  break;
406  default:
407  ARM_COMPUTE_ERROR("Data type not supported");
408  break;
409  }
410  }
411  else
412  {
413  switch(_input->info()->data_type())
414  {
415  case DataType::F32:
416  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<float, false, false> : &NEIm2ColKernel::run_im2col<float, true, false>;
417  break;
418 #if defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) || defined(ARM_COMPUTE_FORCE_BF16)
419  case DataType::BFLOAT16:
420  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<bfloat16, false, false> : &NEIm2ColKernel::run_im2col<bfloat16, true, false>;
421  break;
422 #endif /* defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) || defined(ARM_COMPUTE_FORCE_BF16) */
423 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
424  case DataType::F16:
425  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<float16_t, false, false> : &NEIm2ColKernel::run_im2col<float16_t, true, false>;
426  break;
427 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
428  case DataType::QASYMM8:
429  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<uint8_t, false, false> : &NEIm2ColKernel::run_im2col<qasymm8_t, true, false>;
430  break;
432  _func = (!conv_info.has_padding()) ? &NEIm2ColKernel::run_im2col<int8_t, false, false> : &NEIm2ColKernel::run_im2col<qasymm8_t, true, false>;
433  break;
434  default:
435  ARM_COMPUTE_ERROR("Data type not supported");
436  break;
437  }
438  }
439 
440  // Configure kernel window
441  auto win_config = validate_and_configure_window(input->info(), output->info(), kernel_dims, conv_info, has_bias, dilation);
442  ARM_COMPUTE_ERROR_THROW_ON(win_config.first);
443  INEKernel::configure(win_config.second);
444 }
445 
446 Status NEIm2ColKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info,
447  bool has_bias, const Size2D &dilation, unsigned int num_groups)
448 {
449  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, kernel_dims, conv_info, has_bias, dilation, num_groups));
450  ARM_COMPUTE_RETURN_ON_ERROR(validate_and_configure_window(input->clone().get(), output->clone().get(), kernel_dims, conv_info, has_bias, dilation).first);
451  return Status{};
452 }
453 
454 void NEIm2ColKernel::run(const Window &window, const ThreadInfo &info)
455 {
456  ARM_COMPUTE_UNUSED(info);
459 
460  (this->*_func)(window);
461 }
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1168
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_RETURN_ERROR_ON_CPU_F16_UNSUPPORTED(tensor)
Definition: Validate.h:108
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_QUANTIZATION_INFO(...)
Definition: Validate.h:610
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
const DataLayout data_layout
Definition: Im2Col.cpp:151
Store the tensor&#39;s metadata.
Definition: ITensorInfo.h:40
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Describe one of the image&#39;s dimensions with a start, end and step.
Definition: Window.h:77
size_t x() const
Semantic accessor for width as x.
Definition: Size2D.h:74
unsigned int pad_top() const
Get the top padding.
Definition: Types.h:806
Status class.
Definition: Error.h:52
SimpleTensor< uint8_t > expected_output(output_shape, DataType::QASYMM8, 1, qasymm)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
Definition: Error.h:296
Interface for Neon tensor.
Definition: ITensor.h:36
Copyright (c) 2017-2021 Arm Limited.
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:90
1 channel, 1 F16 per channel
std::pair< unsigned int, unsigned int > scaled_dimensions(int width, int height, int kernel_width, int kernel_height, const PadStrideInfo &pad_stride_info, const Size2D &dilation=Size2D(1U, 1U))
Returns expected width and height of output scaled tensor depending on dimensions rounding mode...
Definition: Utils.cpp:419
ITensorInfo * info() const override
Interface to be implemented by the child class to return the tensor&#39;s metadata.
Definition: Tensor.cpp:33
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
16-bit brain floating-point number
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
quantized, asymmetric fixed-point 8-bit number unsigned
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
const unsigned int num_groups
Definition: Im2Col.cpp:153
Coordinates of an item.
Definition: Coordinates.h:37
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
NEIm2ColKernel()
Default constructor.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor&#39;s metadata.
unsigned int pad_right() const
Get the right padding.
Definition: Types.h:801
Padding and stride information class.
Definition: Types.h:722
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
Num samples, channels, height, width.
size_t y() const
Semantic accessor for height as y.
Definition: Size2D.h:83
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
Definition: CPPTypes.h:235
virtual size_t total_size() const =0
Returns the total size of the tensor in bytes.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:443
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:89
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
Class for specifying the size of an image or rectangle.
Definition: Size2D.h:34
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:792
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
void configure(const ITensor *input, ITensor *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const Size2D &dilation=Size2D(1U, 1U), unsigned int num_groups=1)
Set the input and output of the kernel.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Definition: Error.h:244
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:45
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Definition: Helpers.inl:77
T y() const
Alias to access the size of the second dimension.
Definition: Dimensions.h:92
quantized, asymmetric fixed-point 8-bit number signed
virtual const Strides & strides_in_bytes() const =0
The strides in bytes for accessing each dimension of the tensor.
Container for valid region of a window.
Definition: Types.h:188
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:193
unsigned int pad_bottom() const
Get the bottom padding.
Definition: Types.h:811
Iterator updated by execute_window_loop for each window element.
Definition: Helpers.h:46
unsigned int pad_left() const
Get the left padding.
Definition: Types.h:796
DataLayout
[DataLayout enum definition]
Definition: Types.h:120
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const Size2D &dilation=Size2D(1U, 1U), unsigned int num_groups=1)
Static function to check if given info will lead to a valid configuration of NEIm2ColKernel.
TensorShape compute_im2col_conv_shape(const ITensorInfo *input, const Size2D &kernel_dims, const PadStrideInfo &conv_info, bool has_bias, const Size2D &dilation, bool batch_size_on_z, unsigned int num_groups=1)
Calculate the im2col output shape of a tensor.
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.