Compute Library
 19.08
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 {
186  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
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  // Create kernel
240  switch(data_layout)
241  {
242  case DataLayout::NCHW:
243  {
244  build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width) + (exclude_padding ? 0 : pool_pad_left)));
245  build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height) + (exclude_padding ? 0 : pool_pad_top)));
246  if(pool_type != PoolingType::MAX)
247  {
248  build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING");
249  }
250 
251  if((pool_size_x == 3) && (pool_size_y == 3) && !is_data_type_quantized_asymmetric(data_type))
252  {
253  // Check if we have pool3x3 with stride_x less equal than 3. In these cases, run an optimized OpenCL kernel where
254  // each thread computes 4 output elements
255  const bool is_pool3x3_stride_le3 = (pool_size_x == 3) && (pool_size_y == 3) && (pool_stride_x <= 3);
256 
257  std::string kernel_name = ((is_pool3x3_stride_le3) ? "pooling_layer_optimized_" : "pooling_layer_")
258  + support::cpp11::to_string(pool_size_x);
259  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
260  }
261  else // Run general case
262  {
263  std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nchw" : "pooling_layer_MxN_nchw";
264  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
265  }
266  break;
267  }
268  case DataLayout::NHWC:
269  {
270  build_opts.add_option_if(exclude_padding, "-DEXCLUDE_PADDING");
271  build_opts.add_option("-DMAX_WIDTH=" + support::cpp11::to_string(input->info()->dimension(idx_width)));
272  build_opts.add_option("-DMAX_HEIGHT=" + support::cpp11::to_string(input->info()->dimension(idx_height)));
273  build_opts.add_option_if(output->info()->tensor_shape().total_size_upper(3) > 1,
274  "-DDST_DEPTH=" + support::cpp11::to_string(output->info()->dimension(idx_height)));
275  std::string kernel_name = is_data_type_quantized_asymmetric(data_type) ? "pooling_layer_MxN_quantized_nhwc" : "pooling_layer_MxN_nhwc";
276  _kernel = static_cast<cl::Kernel>(CLKernelLibrary::get().create_kernel(kernel_name, build_opts.options()));
277  break;
278  }
279  default:
280  ARM_COMPUTE_ERROR("Not implemented");
281  }
282 
283  // Configure kernel window
284  auto win_config = validate_and_configure_window(input->info(), output->info(), pool_info);
285 
286  ARM_COMPUTE_ERROR_THROW_ON(std::get<0>(win_config));
287  ICLKernel::configure_internal(std::get<1>(win_config));
288 
290  {
291  CLPoolingConfig pooling_config = std::get<2>(win_config);
292  _num_elems_processed_per_iteration = pooling_config.first;
293  _border_size = pooling_config.second;
294  }
295  else
296  {
297  _border_size = BorderSize(1, 0, 0, 0);
299  }
300 
301  // Set config_id for enabling LWS tuning
302  _config_id = "pooling_layer_";
304  _config_id += "_";
306  _config_id += "_";
307  _config_id += support::cpp11::to_string(output->info()->dimension(idx_width));
308  _config_id += "_";
309  _config_id += support::cpp11::to_string(output->info()->dimension(idx_height));
310  _config_id += "_";
311  _config_id += support::cpp11::to_string(output->info()->dimension(idx_channel));
312  _config_id += "_";
313  _config_id += lower_string(string_from_data_layout(input->info()->data_layout()));
314 }
bool exclude_padding() const
Check if padding is excluded in calculations.
Definition: Types.h:1257
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
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:259
const StringSet & options() const
Gets the current options list set.
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
std::string to_string(T &&value)
Convert integer and float values to string.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
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:327
Quantization info when assuming per layer quantization.
unsigned int pad_top() const
Get the top padding.
Definition: Types.h:760
std::string lower_string(const std::string &val)
Lower a given string.
Definition: Utils.cpp:327
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:1066
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:724
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:35
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:676
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:1252
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1030
const Size2D & pool_size() const
Get the pooling size.
Definition: Types.h:1247
PoolingType
Available pooling types.
Definition: Types.h:564
#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:1242
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:326
DataType
Available data types.
Definition: Types.h:74
unsigned int pad_left() const
Get the left padding.
Definition: Types.h:750
DataLayout
[DataLayout enum definition]
Definition: Types.h:114
const std::string & string_from_pooling_type(PoolingType type)
Translates a given pooling type to a string.
Definition: Utils.cpp:252
bool is_global_pooling() const
Check if is global pooling.
Definition: Types.h:1262
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

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, ITensorInfo::data_layout(), arm_compute::test::validation::data_type, ITensorInfo::data_type(), ITensorInfo::dimension(), PoolingLayerInfo::exclude_padding(), arm_compute::F16, arm_compute::float_to_string_with_full_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::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(), arm_compute::validate_and_configure_window(), 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 324 of file CLPoolingLayerKernel.cpp.

325 {
328 
329  unsigned int pool_stride_x = 0;
330  unsigned int pool_stride_y = 0;
331  std::tie(pool_stride_x, pool_stride_y) = _pool_info.pad_stride_info().stride();
332 
333  // Collapse window
335 
336  switch(_input->info()->data_layout())
337  {
338  case DataLayout::NCHW:
339  {
340  Window slice = window_collapsed.first_slice_window_3D();
341  do
342  {
343  // Upsample input by pool size
344  Window in_slice(slice);
345  in_slice.set(Window::DimX, Window::Dimension(in_slice.x().start() - _pool_info.pad_stride_info().pad_left(),
346  (in_slice.x().end() - _pool_info.pad_stride_info().pad_left()) * pool_stride_x,
347  pool_stride_x * _num_elems_processed_per_iteration));
348  in_slice.set(Window::DimY, Window::Dimension(in_slice.y().start() - _pool_info.pad_stride_info().pad_top(),
349  (in_slice.y().end() - _pool_info.pad_stride_info().pad_top()) * pool_stride_y,
350  pool_stride_y));
351 
352  // Set inputs
353  unsigned int idx = 0;
354  add_3D_tensor_argument(idx, _input, in_slice);
356  enqueue(queue, *this, slice, lws_hint());
357  }
358  while(window_collapsed.slide_window_slice_3D(slice));
359  break;
360  }
361  case DataLayout::NHWC:
362  {
363  const size_t total_batches = _output->info()->tensor_shape().total_size_upper(3);
364 
365  Window slice = window_collapsed.first_slice_window_4D();
366  Window in_slice = window_collapsed.first_slice_window_4D();
368  in_slice.set(Window::DimY, Window::Dimension(0, _input->info()->dimension(1), pool_stride_x));
369  in_slice.set(Window::DimZ, Window::Dimension(0, _input->info()->dimension(2), pool_stride_y));
370  in_slice.set(3, Window::Dimension(0, total_batches, 1));
371  do
372  {
373  // Set inputs
374  unsigned int idx = 0;
375  add_4D_tensor_argument(idx, _input, in_slice);
377  enqueue(queue, *this, slice, lws_hint());
378  }
380  break;
381  }
382  default:
383  ARM_COMPUTE_ERROR("Not implemented");
384  }
385 }
#define ARM_COMPUTE_ERROR(...)
Print the given message then throw an std::runtime_error.
Definition: Error.h:261
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
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:760
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:54
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:724
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:48
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
Definition: Window.h:319
Num samples, channels, height, width.
PadStrideInfo pad_stride_info() const
Get the padding and stride.
Definition: Types.h:1252
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:283
bool slide_window_slice_4D(Window &slice) const
Slide the passed 4D window slice.
Definition: Window.h:331
Window first_slice_window_3D() const
First 3D slice of the window.
Definition: Window.h:275
#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:750
Describe a multidimensional execution window.
Definition: Window.h:39
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940
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 316 of file CLPoolingLayerKernel.cpp.

317 {
318  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, pool_info));
319  ARM_COMPUTE_RETURN_ON_ERROR(std::get<0>(validate_and_configure_window(input->clone().get(), output->clone().get(), pool_info)));
320 
321  return Status{};
322 }
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *input, ITensorInfo *weights, ITensorInfo *biases, ITensorInfo *output, const PadStrideInfo &conv_info, unsigned int depth_multiplier, const Size2D &dilation)
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:193
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::validate_and_configure_window().

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: