Compute Library
 19.11
CLPoolingLayerKernel Class Reference

Interface for the pooling layer kernel. More...

#include <CLPoolingLayerKernel.h>

Collaboration diagram for CLPoolingLayerKernel:
[legend]

Public Member Functions

 CLPoolingLayerKernel ()
 Default constructor. More...
 
 CLPoolingLayerKernel (const CLPoolingLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
CLPoolingLayerKerneloperator= (const CLPoolingLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 CLPoolingLayerKernel (CLPoolingLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
CLPoolingLayerKerneloperator= (CLPoolingLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~CLPoolingLayerKernel ()=default
 Default destructor. More...
 
void configure (const ICLTensor *input, ICLTensor *output, const PoolingLayerInfo &pool_info)
 Set the input and output tensors. More...
 
void run (const Window &window, cl::CommandQueue &queue) override
 Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue. More...
 
BorderSize border_size () const override
 The size of the border for that kernel. More...
 
- Public Member Functions inherited from ICLKernel
 ICLKernel ()
 Constructor. More...
 
cl::Kernel & kernel ()
 Returns a reference to the OpenCL kernel of this object. More...
 
template<typename T >
void add_1D_array_argument (unsigned int &idx, const ICLArray< T > *array, const Strides &strides, unsigned int num_dimensions, const Window &window)
 Add the passed 1D array's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_1D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_1D_tensor_argument_if (bool cond, unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 1D tensor's parameters to the object's kernel's arguments starting from the index idx if the condition is true. More...
 
void add_2D_tensor_argument (unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx. More...
 
void add_2D_tensor_argument_if (bool cond, unsigned int &idx, const ICLTensor *tensor, const Window &window)
 Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx if the condition is true. More...
 
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. More...
 
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. More...
 
template<typename T >
void add_argument (unsigned int &idx, T value)
 Add the passed parameters to the object's kernel's arguments starting from the index idx. More...
 
void set_lws_hint (const cl::NDRange &lws_hint)
 Set the Local-Workgroup-Size hint. More...
 
cl::NDRange lws_hint () const
 Return the Local-Workgroup-Size hint. More...
 
const std::string & config_id () const
 Get the configuration ID. More...
 
void set_target (GPUTarget target)
 Set the targeted GPU architecture. More...
 
void set_target (cl::Device &device)
 Set the targeted GPU architecture according to the CL device. More...
 
GPUTarget get_target () const
 Get the targeted GPU architecture. More...
 
size_t get_max_workgroup_size ()
 Get the maximum workgroup size for the device the CLKernelLibrary uses. More...
 
template<typename T , unsigned int dimension_size>
void add_array_argument (unsigned &idx, const ICLArray< T > *array, const Strides &strides, unsigned int num_dimensions, const Window &window)
 Add the passed array's parameters to the object's kernel's arguments starting from the index idx. More...
 
template<unsigned int dimension_size>
void add_tensor_argument (unsigned &idx, const ICLTensor *tensor, const Window &window)
 
- Public Member Functions inherited from IKernel
 IKernel ()
 Constructor. More...
 
virtual ~IKernel ()=default
 Destructor. More...
 
virtual bool is_parallelisable () const
 Indicates whether or not the kernel is parallelisable. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, const PoolingLayerInfo &pool_info)
 Static function to check if given info will lead to a valid configuration of CLPoolingLayerKernel. More...
 
- Static Public Member Functions inherited from ICLKernel
static constexpr unsigned int num_arguments_per_1D_array ()
 Returns the number of arguments enqueued per 1D array object. More...
 
static constexpr unsigned int num_arguments_per_1D_tensor ()
 Returns the number of arguments enqueued per 1D tensor object. More...
 
static constexpr unsigned int num_arguments_per_2D_tensor ()
 Returns the number of arguments enqueued per 2D tensor object. More...
 
static constexpr unsigned int num_arguments_per_3D_tensor ()
 Returns the number of arguments enqueued per 3D tensor object. More...
 
static constexpr unsigned int num_arguments_per_4D_tensor ()
 Returns the number of arguments enqueued per 4D tensor object. More...
 
static cl::NDRange gws_from_window (const Window &window)
 Get the global work size given an execution window. More...
 

Data Fields

const ICLTensor_input
 
ICLTensor_output
 
PoolingLayerInfo _pool_info
 
BorderSize _border_size
 
unsigned int _num_elems_processed_per_iteration
 

Detailed Description

Interface for the pooling layer kernel.

Definition at line 36 of file CLPoolingLayerKernel.h.

Constructor & Destructor Documentation

◆ CLPoolingLayerKernel() [1/3]

◆ CLPoolingLayerKernel() [2/3]

Prevent instances of this class from being copied (As this class contains pointers)

◆ CLPoolingLayerKernel() [3/3]

Allow instances of this class to be moved.

◆ ~CLPoolingLayerKernel()

~CLPoolingLayerKernel ( )
default

Default destructor.

Member Function Documentation

◆ border_size()

BorderSize border_size ( ) const
overridevirtual

The size of the border for that kernel.

Returns
The width in number of elements of the border.

Reimplemented from IKernel.

Definition at line 179 of file CLPoolingLayerKernel.cpp.

180 {
181  return _border_size;
182 }

References CLPoolingLayerKernel::_border_size.

◆ configure()

void configure ( const ICLTensor input,
ICLTensor output,
const PoolingLayerInfo pool_info 
)

Set the input and output tensors.

Parameters
[in]inputSource tensor. Data types supported: QASYMM8/F16/F32.
[out]outputDestination tensor. Data types supported: Same as input.
[in]pool_infoContains pooling operation information described in PoolingLayerInfo.

Definition at line 184 of file CLPoolingLayerKernel.cpp.

185 {
187 
188  int pool_stride_x = 0;
189  int pool_stride_y = 0;
190  const PoolingType pool_type = pool_info.pool_type();
191  DataLayout data_layout = input->info()->data_layout();
195  const int pool_size_x = pool_info.is_global_pooling() ? input->info()->dimension(idx_width) : pool_info.pool_size().width;
196  const int pool_size_y = pool_info.is_global_pooling() ? input->info()->dimension(idx_height) : pool_info.pool_size().height;
197  const PadStrideInfo pad_stride_info = pool_info.pad_stride_info();
198  const bool exclude_padding = pool_info.exclude_padding();
199  std::tie(pool_stride_x, pool_stride_y) = pad_stride_info.stride();
200  const int pool_pad_top = pad_stride_info.pad_top();
201  const int pool_pad_left = pad_stride_info.pad_left();
202 
203  // Set build options
204  CLBuildOptions build_opts;
205 
206  if(is_data_type_quantized_asymmetric(input->info()->data_type()) && input->info()->quantization_info() != output->info()->quantization_info())
207  {
208  const UniformQuantizationInfo iq_info = input->info()->quantization_info().uniform();
209  const UniformQuantizationInfo oq_info = output->info()->quantization_info().uniform();
210 
211  build_opts.add_option("-DOFFSET_IN1=" + float_to_string_with_full_precision(iq_info.offset));
212  build_opts.add_option("-DOFFSET_OUT=" + float_to_string_with_full_precision(oq_info.offset));
213  build_opts.add_option("-DSCALE_IN1=" + float_to_string_with_full_precision(iq_info.scale));
214  build_opts.add_option("-DSCALE_OUT=" + float_to_string_with_full_precision(oq_info.scale));
215  }
216 
217  // Check output dimensions
218  auto_init(input->info(), output->info(), pool_info);
219  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), pool_info));
220 
221  // Set instance variables
222  _input = input;
223  _output = output;
224  _pool_info = pool_info;
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  build_opts.add_option_if(data_type == DataType::F16, "-DFP16");
238 
239  const auto use_fp_mixed_precision = (data_type == DataType::F16) && pool_info.fp_mixed_precision();
240  const auto use_wider_accumulator = use_fp_mixed_precision && (pool_type != PoolingType::MAX);
241  const auto acc_data_type = get_cl_type_from_data_type(use_wider_accumulator ? DataType::F32 : data_type);
242  build_opts.add_option("-DACC_DATA_TYPE=" + acc_data_type);
243  build_opts.add_option_if(use_wider_accumulator, "-DFP_MIXED_PRECISION");
244 
245  // Create kernel
246  switch(data_layout)
247  {
248  case DataLayout::NCHW:
249  {
250  build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width) + (exclude_padding ? 0 : pool_pad_left)));
251  build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height) + (exclude_padding ? 0 : pool_pad_top)));
252  if(pool_type != PoolingType::MAX)
253  {
254  build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING");
255  }
256 
257  if((pool_size_x == 3) && (pool_size_y == 3) && !is_data_type_quantized_asymmetric(data_type))
258  {
259  // Check if we have pool3x3 with stride_x less equal than 3. In these cases, run an optimized OpenCL kernel where
260  // each thread computes 4 output elements
261  const bool is_pool3x3_stride_le3 = (pool_size_x == 3) && (pool_size_y == 3) && (pool_stride_x <= 3);
262 
263  std::string kernel_name = ((is_pool3x3_stride_le3) ? "pooling_layer_optimized_" : "pooling_layer_")
264  + support::cpp11::to_string(pool_size_x);
265  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
266  }
267  else // Run general case
268  {
269  std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nchw" : "pooling_layer_MxN_nchw";
270  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
271  }
272  break;
273  }
274  case DataLayout::NHWC:
275  {
276  build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING");
277  build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width)));
278  build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height)));
279  build_opts.add_option_if(output->info()->tensor_shape().total_size_upper(3) > 1,
280  "-DDST_DEPTH=" + support::cpp11::to_string(output->info()->dimension(idx_height)));
281  std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nhwc" : "pooling_layer_MxN_nhwc";
282  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
283  break;
284  }
285  default:
286  ARM_COMPUTE_ERROR("Not implemented");
287  }
288 
289  // Configure kernel window
290  auto win_config = validate_and_configure_window(input->info(), output->info(), pool_info);
291 
292  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
293  ICLKernel::configure_internal(std::get<1>(win_config));
294 
296  {
297  CLPoolingConfig pooling_config = std::get<2>(win_config);
298  _num_elems_processed_per_iteration = pooling_config.first;
299  _border_size = pooling_config.second;
300  }
301  else
302  {
303  _border_size = BorderSize(1, 0, 0, 0);
305  }
306 
307  // Set config_id for enabling LWS tuning
308  _config_id = "pooling_layer_";
310  _config_id += "_";
312  _config_id += "_";
313  _config_id += support::cpp11::to_string(output->info()->dimension(idx_width));
314  _config_id += "_";
315  _config_id += support::cpp11::to_string(output->info()->dimension(idx_height));
316  _config_id += "_";
317  _config_id += support::cpp11::to_string(output->info()->dimension(idx_channel));
318  _config_id += "_";
319  _config_id += lower_string(string_from_data_layout(input->info()->data_layout()));
320 }
bool exclude_padding() const
Check if padding is excluded in calculations.
Definition: Types.h:1281
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:268
const StringSet & options() const
Gets the current options list set.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Definition: Error.h:352
std::string to_string(T &&value)
Convert integer and float values to string.
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.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
Quantization info when assuming per layer quantization.
unsigned int pad_top() const
Get the top padding.
Definition: Types.h:769
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:333
size_t height
Height of the image region or rectangle.
Definition: Size2D.h:93
1 channel, 1 F16 per channel
void add_option(std::string option)
Adds option to the existing build option list.
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
Definition: Utils.cpp:144
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
Definition: Utils.h:1099
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
Definition: Types.h:733
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 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:685
std::unique_ptr< Kernel > create_kernel()
Helper function to create and return a unique_ptr pointed to a CL/GLES kernel object.
Definition: Helpers.h:86
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
Num samples, channels, height, width.
PadStrideInfo pad_stride_info() const
Get the padding and stride.
Definition: Types.h:1276
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1044
const Size2D & pool_size() const
Get the pooling size.
Definition: Types.h:1271
PoolingType
Available pooling types.
Definition: Types.h:573
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
Definition: Utils.cpp:132
size_t width
Width of the image region or rectangle.
Definition: Size2D.h:92
PoolingType pool_type() const
Get the pooling type.
Definition: Types.h:1266
Num samples, height, width, channels.
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
bool fp_mixed_precision() const
Check if a wider accumulator should be used.
Definition: Types.h:1286
DataType
Available data types.
Definition: Types.h:74
unsigned int pad_left() const
Get the left padding.
Definition: Types.h:759
DataLayout
[DataLayout enum definition]
Definition: Types.h:116
const std::string & string_from_pooling_type(PoolingType type)
Translates a given pooling type to a string.
Definition: Utils.cpp:255
bool is_global_pooling() const
Check if is global pooling.
Definition: Types.h:1291

References CLPoolingLayerKernel::_border_size, CLPoolingLayerKernel::_input, CLPoolingLayerKernel::_num_elems_processed_per_iteration, CLPoolingLayerKernel::_output, CLPoolingLayerKernel::_pool_info, CLBuildOptions::add_option(), CLBuildOptions::add_option_if(), ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::CHANNEL, arm_compute::create_kernel(), arm_compute::test::validation::data_layout, arm_compute::test::validation::data_type, ITensorInfo::dimension(), PoolingLayerInfo::exclude_padding(), arm_compute::F16, arm_compute::F32, arm_compute::float_to_string_with_full_precision(), PoolingLayerInfo::fp_mixed_precision(), CLKernelLibrary::get(), arm_compute::get_cl_type_from_data_type(), arm_compute::get_data_layout_dimension_index(), Size2D::height, arm_compute::HEIGHT, ITensor::info(), arm_compute::test::validation::input, arm_compute::is_data_type_quantized_asymmetric(), PoolingLayerInfo::is_global_pooling(), arm_compute::lower_string(), arm_compute::MAX, arm_compute::NCHW, arm_compute::NHWC, UniformQuantizationInfo::offset, CLBuildOptions::options(), PadStrideInfo::pad_left(), PoolingLayerInfo::pad_stride_info(), PadStrideInfo::pad_top(), PoolingLayerInfo::pool_size(), PoolingLayerInfo::pool_type(), ITensorInfo::quantization_info(), UniformQuantizationInfo::scale, PadStrideInfo::stride(), arm_compute::string_from_data_layout(), arm_compute::string_from_data_type(), arm_compute::string_from_pooling_type(), ITensorInfo::tensor_shape(), arm_compute::support::cpp11::to_string(), TensorShape::total_size_upper(), QuantizationInfo::uniform(), Size2D::width, and arm_compute::WIDTH.

◆ operator=() [1/2]

CLPoolingLayerKernel& operator= ( const CLPoolingLayerKernel )
delete

Prevent instances of this class from being copied (As this class contains pointers)

◆ operator=() [2/2]

CLPoolingLayerKernel& operator= ( CLPoolingLayerKernel &&  )
default

Allow instances of this class to be moved.

◆ run()

void run ( const Window window,
cl::CommandQueue &  queue 
)
overridevirtual

Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.

Note
The queue is not flushed by this method, and therefore the kernel will not have been executed by the time this method returns.
Parameters
[in]windowRegion on which to execute the kernel. (Must be a valid region of the window returned by window()).
[in,out]queueCommand queue on which to enqueue the kernel.

Implements ICLKernel.

Definition at line 330 of file CLPoolingLayerKernel.cpp.

331 {
334 
335  unsigned int pool_stride_x = 0;
336  unsigned int pool_stride_y = 0;
337  std::tie(pool_stride_x, pool_stride_y) = _pool_info.pad_stride_info().stride();
338 
339  // Collapse window
341 
342  switch(_input->info()->data_layout())
343  {
344  case DataLayout::NCHW:
345  {
346  Window slice = window_collapsed.first_slice_window_3D();
347  do
348  {
349  // Upsample input by pool size
350  Window in_slice(slice);
351  in_slice.set(Window::DimX, Window::Dimension(in_slice.x().start() - _pool_info.pad_stride_info().pad_left(),
352  (in_slice.x().end() - _pool_info.pad_stride_info().pad_left()) * pool_stride_x,
353  pool_stride_x * _num_elems_processed_per_iteration));
354  in_slice.set(Window::DimY, Window::Dimension(in_slice.y().start() - _pool_info.pad_stride_info().pad_top(),
355  (in_slice.y().end() - _pool_info.pad_stride_info().pad_top()) * pool_stride_y,
356  pool_stride_y));
357 
358  // Set inputs
359  unsigned int idx = 0;
360  add_3D_tensor_argument(idx, _input, in_slice);
362  enqueue(queue, *this, slice, lws_hint());
363  }
364  while(window_collapsed.slide_window_slice_3D(slice));
365  break;
366  }
367  case DataLayout::NHWC:
368  {
369  const size_t total_batches = _output->info()->tensor_shape().total_size_upper(3);
370 
371  Window slice = window_collapsed.first_slice_window_4D();
372  Window in_slice = window_collapsed.first_slice_window_4D();
374  in_slice.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), pool_stride_x));
375  in_slice.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), pool_stride_y));
376  in_slice.set(3, Window::Dimension(0, total_batches, 1));
377  do
378  {
379  // Set inputs
380  unsigned int idx = 0;
381  add_4D_tensor_argument(idx, _input, in_slice);
383  enqueue(queue, *this, slice, lws_hint());
384  }
386  break;
387  }
388  default:
389  ARM_COMPUTE_ERROR("Not implemented");
390  }
391 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
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_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
size_t total_size_upper(size_t dimension) const
Collapses given dimension and above.
Definition: TensorShape.h:181
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:769
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
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
Definition: Window.h:43
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
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
std::pair< unsigned int, unsigned int > stride() const
Get the stride.
Definition: Types.h:733
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
Definition: Window.inl:49
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:333
Num samples, channels, height, width.
PadStrideInfo pad_stride_info() const
Get the padding and stride.
Definition: Types.h:1276
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
Definition: Window.h:47
Num samples, height, width, channels.
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
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:289
#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:759
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)
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

References CLPoolingLayerKernel::_input, CLPoolingLayerKernel::_num_elems_processed_per_iteration, CLPoolingLayerKernel::_output, CLPoolingLayerKernel::_pool_info, ICLKernel::add_3D_tensor_argument(), ICLKernel::add_4D_tensor_argument(), ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, Window::collapse_if_possible(), ITensorInfo::data_layout(), ITensorInfo::dimension(), Window::DimX, Window::DimY, Window::DimZ, Window::Dimension::end(), arm_compute::enqueue(), Window::first_slice_window_3D(), Window::first_slice_window_4D(), ITensor::info(), ICLKernel::lws_hint(), arm_compute::NCHW, arm_compute::NHWC, PadStrideInfo::pad_left(), PoolingLayerInfo::pad_stride_info(), PadStrideInfo::pad_top(), Window::set(), arm_compute::test::validation::reference::slice(), Window::slide_window_slice_3D(), Window::slide_window_slice_4D(), Window::Dimension::start(), PadStrideInfo::stride(), ITensorInfo::tensor_shape(), TensorShape::total_size_upper(), IKernel::window(), Window::x(), and Window::y().

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo output,
const PoolingLayerInfo pool_info 
)
static

Static function to check if given info will lead to a valid configuration of CLPoolingLayerKernel.

Parameters
[in]inputSource tensor info. Data types supported: QASYMM8/F16/F32.
[in]outputDestination tensor info. Data types supported: Same as input.
[in]pool_infoContains pooling operation information described in PoolingLayerInfo.
Returns
a status

Definition at line 322 of file CLPoolingLayerKernel.cpp.

323 {
324  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, pool_info));
325  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), pool_info)));
326 
327  return Status{};
328 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
Status class.
Definition: Error.h:52
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.

References ARM_COMPUTE_RETURN_ON_ERROR, ICloneable< T >::clone(), and arm_compute::test::validation::input.

Referenced by CLPoolingLayer::validate().

Field Documentation

◆ _border_size

◆ _input

const ICLTensor* _input

◆ _num_elems_processed_per_iteration

unsigned int _num_elems_processed_per_iteration

◆ _output

ICLTensor* _output

◆ _pool_info


The documentation for this class was generated from the following files: