Compute Library
 19.08
CLPoolingLayer Class Reference

Basic function to simulate a pooling layer with the specified pooling operation. More...

#include <CLPoolingLayer.h>

Collaboration diagram for CLPoolingLayer:
[legend]

Public Member Functions

void configure (ICLTensor *input, ICLTensor *output, const PoolingLayerInfo &pool_info)
 Set the input and output tensors. More...
 
- Public Member Functions inherited from ICLSimpleFunction
 ICLSimpleFunction ()
 Default constructor. More...
 
void run () override final
 Run the kernels contained in the function. More...
 
- Public Member Functions inherited from IFunction
virtual ~IFunction ()=default
 Destructor. More...
 
virtual void prepare ()
 Prepare the function for executing. 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 CLPoolingLayer. More...
 

Detailed Description

Basic function to simulate a pooling layer with the specified pooling operation.

This function calls the following OpenCL kernels:

  1. CLFillBorderKernel (executed if padding size is different from zero)
  2. CLPoolingLayerKernel

Definition at line 41 of file CLPoolingLayer.h.

Member Function Documentation

◆ configure()

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

Set the input and output tensors.

Parameters
[in,out]inputSource tensor. (Written to only when padding != 0) 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 33 of file CLPoolingLayer.cpp.

34 {
36 
37  // Configure pooling kernel
38  auto k = arm_compute::support::cpp14::make_unique<CLPoolingLayerKernel>();
39  k->set_target(CLScheduler::get().target());
40  k->configure(input, output, pool_info);
41  _kernel = std::move(k);
42 
43  // Configure border depending on operation required (quantize border in case of asymmetric data_type)
45  PixelValue pixel_value(0.f);
46  if(is_data_type_quantized_asymmetric(input->info()->data_type()) && !pool_info.exclude_padding())
47  {
48  pixel_value = PixelValue(static_cast<uint32_t>(input->info()->quantization_info().uniform().offset));
49  }
50  switch(input->info()->data_layout())
51  {
52  case DataLayout::NCHW:
54  break;
55  case DataLayout::NHWC:
58  {
60  }
61  break;
62  default:
63  ARM_COMPUTE_ERROR("Data layout not supported");
64  }
65  _border_handler.configure(input, _kernel->border_size(), border_mode, pixel_value);
66 
67  // Tune kernels
69 }
BorderMode
Methods available to handle borders.
Definition: Types.h:251
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
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
static CLScheduler & get()
Access the scheduler singleton.
Definition: CLScheduler.cpp:41
virtual DataType data_type() const =0
Data type used for each element of the tensor.
UniformQuantizationInfo uniform() const
Return per layer quantization info.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
Num samples, channels, height, width.
bool is_data_type_quantized_asymmetric(DataType dt)
Check if a given data type is of asymmetric quantized type.
Definition: Utils.h:1030
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
Pixels outside the image are assumed to have the same value as the closest image pixel.
PoolingType pool_type() const
Get the pooling type.
Definition: Types.h:1242
Num samples, height, width, channels.
void tune_kernel_static(ICLKernel &kernel)
Tunes OpenCL kernel.
Definition: CLScheduler.h:172
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_NULLPTR, arm_compute::test::validation::border_mode, arm_compute::CONSTANT, ITensorInfo::data_layout(), ITensorInfo::data_type(), PoolingLayerInfo::exclude_padding(), CLScheduler::get(), ITensor::info(), arm_compute::is_data_type_quantized_asymmetric(), arm_compute::support::cpp11::lowest(), arm_compute::MAX, arm_compute::NCHW, arm_compute::NHWC, UniformQuantizationInfo::offset, PoolingLayerInfo::pool_type(), ITensorInfo::quantization_info(), arm_compute::REPLICATE, CLScheduler::tune_kernel_static(), and QuantizationInfo::uniform().

◆ 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 CLPoolingLayer.

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 71 of file CLPoolingLayer.cpp.

72 {
73  return CLPoolingLayerKernel::validate(input, output, pool_info);
74 }
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.

References CLPoolingLayerKernel::validate().


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