Compute Library
 20.05
CLPoolingLayerKernel.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 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 
35 #include "arm_compute/core/Utils.h"
38 #include "support/StringSupport.h"
39 
40 #include <set>
41 #include <string>
42 #include <tuple>
43 
44 namespace arm_compute
45 {
47 
48 namespace
49 {
50 // Internal window config info
51 using CLPoolingConfig = std::pair<unsigned int, BorderSize>; //num_elems_processed_per_iteration, border_size
52 
53 void auto_init(const ITensorInfo *input, ITensorInfo *output, PoolingLayerInfo pool_info)
54 {
55  TensorShape out_shape = compute_pool_shape(*input, pool_info);
56  auto_init_if_empty(*output, input->clone()->set_tensor_shape(out_shape));
57 }
58 
59 Status validate_arguments(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info, const ITensorInfo *indices)
60 {
63  ARM_COMPUTE_RETURN_ERROR_ON_MSG(indices, "Indices not supported in the CL backend.");
66  "Unsupported combination of parameters!");
67  ARM_COMPUTE_RETURN_ERROR_ON_MSG(is_data_type_quantized(input->data_type()) && !pool_info.exclude_padding && (pool_info.pool_type == PoolingType::AVG) && pool_info.pad_stride_info.has_padding()
68  && (input->data_layout() == DataLayout::NHWC),
69  "exclude_padding equal false is not supported for AVG Pooling with padding on quantized types");
70 
71  // Checks performed when output is configured
72  if(output->total_size() != 0)
73  {
76  TensorInfo out_info(TensorInfo(compute_pool_shape(*input, pool_info), 1, output->data_type()));
78  }
79 
80  return Status{};
81 }
82 
83 std::tuple<Status, Window, CLPoolingConfig> validate_and_configure_window(ITensorInfo *input, ITensorInfo *output, const PoolingLayerInfo &pool_info)
84 {
86 
87  // Get data layout
88  const DataLayout data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? input->data_layout() : pool_info.data_layout;
91 
92  int pool_stride_x = 0;
93  int pool_stride_y = 0;
94  unsigned int pooled_w = 0;
95  unsigned int pooled_h = 0;
96  int pool_size_x = pool_info.is_global_pooling ? input->dimension(idx_width) : pool_info.pool_size.width;
97  int pool_size_y = pool_info.is_global_pooling ? input->dimension(idx_height) : pool_info.pool_size.height;
98  const PadStrideInfo pad_stride_info = pool_info.pad_stride_info;
99  std::tie(pool_stride_x, pool_stride_y) = pad_stride_info.stride();
100  const int pool_pad_right = pad_stride_info.pad_right();
101  const int pool_pad_top = pad_stride_info.pad_top();
102  const int pool_pad_left = pad_stride_info.pad_left();
103  const int pool_pad_bottom = pad_stride_info.pad_bottom();
104  BorderSize border_size = BorderSize(pool_pad_top, pool_pad_right, pool_pad_bottom, pool_pad_left);
105 
106  auto_init(input, output, pool_info);
107  pooled_w = output->tensor_shape()[idx_width];
108  pooled_h = output->tensor_shape()[idx_height];
109 
110  const DataType data_type = input->data_type();
111 
112  const int input_width = input->dimension(idx_width);
113  const int input_height = input->dimension(idx_height);
114 
115  unsigned int num_elems_processed_per_iteration = 0;
116  bool window_changed = false;
117  Window win{};
118  switch(data_layout)
119  {
120  case DataLayout::NCHW:
121  {
122  // Change the number of elements processed per iteration
123  // for pooling 3x3 with stride less equal than 3
124  const bool can_optimize = (pool_size_x == 3) && (pool_size_y == 3) && (pool_stride_x <= 3) && !is_data_type_quantized(data_type);
125  num_elems_processed_per_iteration = can_optimize ? 4 : 1;
126  const unsigned int num_elems_read_per_iteration = (num_elems_processed_per_iteration - 1) * pool_stride_x + pool_size_x;
127 
128  // Number of iterations in X dimension
129  const int num_iterations_x = (pooled_w + num_elems_processed_per_iteration - 1) / num_elems_processed_per_iteration;
130 
131  // Upper limit for the number of right/bottom border elements that are accessed
132  const int upper_bound_w = ((num_iterations_x - 1) * num_elems_processed_per_iteration * pool_stride_x - pool_pad_left + num_elems_read_per_iteration) - input_width;
133  const int upper_bound_h = ((pooled_h - 1) * pool_stride_y - pool_pad_top + pool_size_y) - input_height;
134 
135  border_size.right = std::max(upper_bound_w, pool_pad_right);
136  border_size.bottom = std::max(upper_bound_h, pool_pad_bottom);
137 
139 
140  AccessWindowRectangle input_access(input, -pool_pad_left, -pool_pad_top, num_elems_read_per_iteration, pool_size_y,
141  pool_stride_x, pool_stride_y);
142  AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration);
143  window_changed = update_window_and_padding(win, input_access, output_access);
144  output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape()));
145  break;
146  }
147  case DataLayout::NHWC:
148  {
151 
152  AccessWindowStatic input_access(input,
153  0, -1,
154  ceil_to_multiple(input->dimension(0), num_elems_processed_per_iteration), input->dimension(1));
155  AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration);
156  window_changed = update_window_and_padding(win, input_access, output_access);
157  output_access.set_valid_region(win, ValidRegion(Coordinates(), output->tensor_shape()));
158  break;
159  }
160  default:
161  ARM_COMPUTE_ERROR("Not implemented");
162  }
163 
164  Status err = (window_changed) ? ARM_COMPUTE_CREATE_ERROR(ErrorCode::RUNTIME_ERROR, "Insufficient Padding!") : Status{};
165  return std::make_tuple(err, win, CLPoolingConfig(num_elems_processed_per_iteration, border_size));
166 }
167 } // namespace
168 
170  : _input(nullptr), _output(nullptr), _indices(nullptr), _pool_info(), _data_layout(DataLayout::UNKNOWN), _border_size(0), _num_elems_processed_per_iteration(1)
171 {
172 }
173 
175 {
176  return _border_size;
177 }
178 
179 void CLPoolingLayerKernel::configure(const ICLTensor *input, ICLTensor *output, const PoolingLayerInfo &pool_info, ICLTensor *indices)
180 {
181  configure(CLKernelLibrary::get().get_compile_context(), input, output, pool_info, indices);
182 }
183 
184 void CLPoolingLayerKernel::configure(const CLCompileContext &compile_context, const ICLTensor *input, ICLTensor *output, const PoolingLayerInfo &pool_info, ICLTensor *indices)
185 {
187 
188  // Set instance variables
189  _input = input;
190  _output = output;
191  _pool_info = pool_info;
192  _data_layout = pool_info.data_layout == DataLayout::UNKNOWN ? input->info()->data_layout() : pool_info.data_layout;
193  _indices = indices;
194  int pool_stride_x = 0;
195  int pool_stride_y = 0;
196  const PoolingType pool_type = pool_info.pool_type;
200  const int pool_size_x = pool_info.is_global_pooling ? input->info()->dimension(idx_width) : pool_info.pool_size.width;
201  const int pool_size_y = pool_info.is_global_pooling ? input->info()->dimension(idx_height) : pool_info.pool_size.height;
202  const PadStrideInfo pad_stride_info = pool_info.pad_stride_info;
203  const bool exclude_padding = pool_info.exclude_padding;
204  std::tie(pool_stride_x, pool_stride_y) = pad_stride_info.stride();
205  const int pool_pad_top = pad_stride_info.pad_top();
206  const int pool_pad_left = pad_stride_info.pad_left();
207 
208  // Set build options
209  CLBuildOptions build_opts;
210 
211  if(is_data_type_quantized_asymmetric(input->info()->data_type()) && input->info()->quantization_info() != output->info()->quantization_info())
212  {
213  const UniformQuantizationInfo iq_info = input->info()->quantization_info().uniform();
214  const UniformQuantizationInfo oq_info = output->info()->quantization_info().uniform();
215 
216  build_opts.add_option("-DOFFSET_IN1=" + float_to_string_with_full_precision(iq_info.offset));
217  build_opts.add_option("-DOFFSET_OUT=" + float_to_string_with_full_precision(oq_info.offset));
218  build_opts.add_option("-DSCALE_IN1=" + float_to_string_with_full_precision(iq_info.scale));
219  build_opts.add_option("-DSCALE_OUT=" + float_to_string_with_full_precision(oq_info.scale));
220  }
221 
222  // Check output dimensions
223  auto_init(input->info(), output->info(), pool_info);
224  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), pool_info, (indices) ? indices->info() : nullptr));
225 
226  const DataType data_type = input->info()->data_type();
227 
228  build_opts.add_option("-DDATA_TYPE=" + get_cl_type_from_data_type(data_type));
229  build_opts.add_option("-DPOOL_" + string_from_pooling_type(pool_type));
230  build_opts.add_option("-DSTRIDE_X=" + support::cpp11::to_string(pool_stride_x));
231  build_opts.add_option("-DSTRIDE_Y=" + support::cpp11::to_string(pool_stride_y));
232  build_opts.add_option("-DPAD_X=" + support::cpp11::to_string(pool_pad_left));
233  build_opts.add_option("-DPAD_Y=" + support::cpp11::to_string(pool_pad_top));
234  build_opts.add_option("-DPOOL_SIZE_X=" + support::cpp11::to_string(pool_size_x));
235  build_opts.add_option("-DPOOL_SIZE_Y=" + support::cpp11::to_string(pool_size_y));
236 
237  // Set the initial value for the pooling operation accordingly with the data type
238  if(pool_type == PoolingType::MAX)
239  {
241  {
243  std::tie(type_min, std::ignore) = get_min_max(data_type);
244  build_opts.add_option("-DINITIAL_VALUE=" + support::cpp11::to_string(type_min.get<int32_t>()));
245  }
246  else
247  {
249  }
250  }
251  else
252  {
253  // Pool AVG and Pool L2 initial value
254  build_opts.add_option("-DINITIAL_VALUE=0");
255  }
256 
257  const auto use_fp_mixed_precision = (data_type == DataType::F16) && pool_info.fp_mixed_precision;
258  const auto use_wider_accumulator = use_fp_mixed_precision && (pool_type != PoolingType::MAX);
259  const auto acc_data_type = get_cl_type_from_data_type(use_wider_accumulator ? DataType::F32 : data_type);
260  build_opts.add_option("-DACC_DATA_TYPE=" + acc_data_type);
261  build_opts.add_option_if(use_wider_accumulator, "-DFP_MIXED_PRECISION");
262 
263  // Create kernel
264  switch(_data_layout)
265  {
266  case DataLayout::NCHW:
267  {
268  build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width) + (exclude_padding ? 0 : pool_pad_left)));
269  build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height) + (exclude_padding ? 0 : pool_pad_top)));
270  if(pool_type != PoolingType::MAX)
271  {
272  build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING");
273  }
274 
275  if((pool_size_x == 3) && (pool_size_y == 3) && !is_data_type_quantized_asymmetric(data_type))
276  {
277  // Check if we have pool3x3 with stride_x less equal than 3. In these cases, run an optimized OpenCL kernel where
278  // each thread computes 4 output elements
279  const bool is_pool3x3_stride_le3 = (pool_size_x == 3) && (pool_size_y == 3) && (pool_stride_x <= 3);
280 
281  std::string kernel_name = ((is_pool3x3_stride_le3) ? "pooling_layer_optimized_" : "pooling_layer_")
282  + support::cpp11::to_string(pool_size_x);
283  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
284  }
285  else // Run general case
286  {
287  std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nchw" : "pooling_layer_MxN_nchw";
288  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
289  }
290  break;
291  }
292  case DataLayout::NHWC:
293  {
294  build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING");
295  build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width)));
296  build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height)));
297  build_opts.add_option_if(output->info()->tensor_shape().total_size_upper(3) > 1,
298  "-DDST_DEPTH=" + support::cpp11::to_string(output->info()->dimension(idx_height)));
299  std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nhwc" : "pooling_layer_MxN_nhwc";
300  _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
301  break;
302  }
303  default:
304  ARM_COMPUTE_ERROR("Not implemented");
305  }
306 
307  // Configure kernel window
308  auto win_config = validate_and_configure_window(input->info(), output->info(), pool_info);
309 
310  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
311  ICLKernel::configure_internal(std::get<1>(win_config));
312 
314  {
315  CLPoolingConfig pooling_config = std::get<2>(win_config);
316  _num_elems_processed_per_iteration = pooling_config.first;
317  _border_size = pooling_config.second;
318  }
319  else
320  {
321  _border_size = BorderSize(1, 0, 0, 0);
323  }
324 
325  // Set config_id for enabling LWS tuning
326  _config_id = "pooling_layer_";
328  _config_id += "_";
330  _config_id += "_";
331  _config_id += support::cpp11::to_string(output->info()->dimension(idx_width));
332  _config_id += "_";
333  _config_id += support::cpp11::to_string(output->info()->dimension(idx_height));
334  _config_id += "_";
335  _config_id += support::cpp11::to_string(output->info()->dimension(idx_channel));
336  _config_id += "_";
337  _config_id += lower_string(string_from_data_layout(input->info()->data_layout()));
338 }
339 
340 Status CLPoolingLayerKernel::validate(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info, const ITensorInfo *indices)
341 {
342  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, pool_info, indices));
343  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), pool_info)));
344 
345  return Status{};
346 }
347 
348 void CLPoolingLayerKernel::run(const Window &window, cl::CommandQueue &queue)
349 {
352 
353  unsigned int pool_stride_x = 0;
354  unsigned int pool_stride_y = 0;
355  std::tie(pool_stride_x, pool_stride_y) = _pool_info.pad_stride_info.stride();
356 
357  // Collapse window
359 
360  switch(_data_layout)
361  {
362  case DataLayout::NCHW:
363  {
364  Window slice = window_collapsed.first_slice_window_3D();
365  do
366  {
367  // Upsample input by pool size
368  Window in_slice(slice);
370  (in_slice.x().end() - _pool_info.pad_stride_info.pad_left()) * pool_stride_x,
371  pool_stride_x * _num_elems_processed_per_iteration));
373  (in_slice.y().end() - _pool_info.pad_stride_info.pad_top()) * pool_stride_y,
374  pool_stride_y));
375 
376  // Set inputs
377  unsigned int idx = 0;
378  add_3D_tensor_argument(idx, _input, in_slice);
380  enqueue(queue, *this, slice, lws_hint());
381  }
382  while(window_collapsed.slide_window_slice_3D(slice));
383  break;
384  }
385  case DataLayout::NHWC:
386  {
387  const size_t total_batches = _output->info()->tensor_shape().total_size_upper(3);
388 
389  Window slice = window_collapsed.first_slice_window_4D();
390  Window in_slice = window_collapsed.first_slice_window_4D();
392  in_slice.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), pool_stride_x));
393  in_slice.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), pool_stride_y));
394  in_slice.set(3, Window::Dimension(0, total_batches, 1));
395  do
396  {
397  // Set inputs
398  unsigned int idx = 0;
399  add_4D_tensor_argument(idx, _input, in_slice);
401  enqueue(queue, *this, slice, lws_hint());
402  }
404  break;
405  }
406  default:
407  ARM_COMPUTE_ERROR("Not implemented");
408  }
409 }
410 } // namespace arm_compute
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Definition: Utils.h:1131
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor)
Definition: CLValidate.h:34
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
const DataLayout data_layout
Definition: Im2Col.cpp:146
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
Container for 2D border size.
Definition: Types.h:272
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.
Definition: ICLKernel.cpp:39
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
Definition: Validate.h:494
const StringSet & options() const
Gets the current options list set.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Definition: Validate.h:545
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
Definition: ICLKernel.h:247
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
std::string to_string(T &&value)
Convert integer and float values to string.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Definition: Validate.h:792
1 channel, 1 F32 per channel
size_t total_size_upper(size_t dimension) const
Collapses given dimension and above.
Definition: TensorShape.h:181
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Store the tensor's metadata.
Definition: ITensorInfo.h:40
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Quantization info when assuming per layer quantization.
Describe one of the image's dimensions with a start, end and step.
Definition: Window.h:75
unsigned int pad_top() const
Get the top padding.
Definition: Types.h:773
Status class.
Definition: Error.h:52
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:326
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps=Steps(), bool skip_border=false, BorderSize border_size=BorderSize())
Calculate the maximum window for a given tensor shape and border setting.
Definition: Helpers.cpp:28
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx.
Definition: ICLKernel.h:158
Copyright (c) 2017-2020 ARM Limited.
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...
Definition: Helpers.inl:202
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:90
1 channel, 1 F16 per channel
void add_option(std::string option)
Adds option to the existing build option list.
TensorShape compute_pool_shape(const ITensorInfo &input, PoolingLayerInfo pool_info)
Calculate the output pool shape of a tensor.
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
Definition: CLHelpers.cpp:387
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
Definition: Utils.cpp:135
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
Definition: Helpers.h:437
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Definition: Window.inl:68
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_SHAPES(...)
Definition: Validate.h:443
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1225
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
auto ceil_to_multiple(S value, T divisor) -> decltype(((value+divisor - 1)/divisor) *divisor)
Computes the smallest number larger or equal to value that is a multiple of divisor.
Definition: Utils.h:67
quantized, asymmetric fixed-point 8-bit number unsigned
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
Definition: Types.h:737
std::string kernel_name
Pooling Layer Information struct.
Definition: Types.h:1181
UniformQuantizationInfo uniform() const
Return per layer quantization info.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
Definition: CLHelpers.cpp:37
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
Padding and stride information class.
Definition: Types.h:689
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
void configure(const ICLTensor *input, ICLTensor *output, const PoolingLayerInfo &pool_info, ICLTensor *indices=nullptr)
Set the input and output tensors.
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:333
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info, const ITensorInfo *indices=nullptr)
Static function to check if given info will lead to a valid configuration of CLPoolingLayerKernel.
Num samples, channels, height, width.
CLCompileContext class.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1153
__constant DATA_TYPE16 type_min
Definition: minmaxloc.cl:46
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:163
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
PoolingType
Available pooling types.
Definition: Types.h:577
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
Definition: Utils.cpp:123
PadStrideInfo pad_stride_info
Definition: Types.h:1269
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
Definition: Error.h:159
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
Num samples, height, width, channels.
constexpr const Dimension & y() const
Alias to access the second dimension of the window.
Definition: Window.h:152
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
Window first_slice_window_4D() const
First 4D slice of the window.
Definition: Window.h:297
bool slide_window_slice_4D(Window &slice) const
Slide the passed 4D window slice.
Definition: Window.h:345
unsigned int num_elems_processed_per_iteration
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Definition: Error.h:244
quantized, asymmetric fixed-point 8-bit number signed
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:327
constexpr int end() const
Return the end of the dimension.
Definition: Window.h:97
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:289
DataType
Available data types.
Definition: Types.h:77
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
void add_4D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 4D tensor's parameters to the object's kernel's arguments starting from the index idx.
Definition: ICLKernel.h:168
unsigned int pad_left() const
Get the left padding.
Definition: Types.h:763
DataLayout
[DataLayout enum definition]
Definition: Types.h:120
const std::string & string_from_pooling_type(PoolingType type)
Translates a given pooling type to a string.
Definition: Utils.cpp:248
constexpr int start() const
Return the start of the dimension.
Definition: Window.h:92
std::tuple< PixelValue, PixelValue > get_min_max(DataType dt)
Compute the mininum and maximum values a data type can take.
Definition: Utils.h:560
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:941
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.
Definition: Window.h:143
BorderSize border_size() const override
The size of the border for that kernel.