Compute Library
 21.08
NEMaxUnpoolingLayerKernel Class Reference

Interface for the pooling layer kernel. More...

#include <NEMaxUnpoolingLayerKernel.h>

Collaboration diagram for NEMaxUnpoolingLayerKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEMaxUnpoolingLayerKernel ()
 Default constructor. More...
 
 NEMaxUnpoolingLayerKernel (const NEMaxUnpoolingLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEMaxUnpoolingLayerKerneloperator= (const NEMaxUnpoolingLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEMaxUnpoolingLayerKernel (NEMaxUnpoolingLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
NEMaxUnpoolingLayerKerneloperator= (NEMaxUnpoolingLayerKernel &&)=default
 Allow instances of this class to be moved. More...
 
 ~NEMaxUnpoolingLayerKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, const ITensor *indices, ITensor *output, const PoolingLayerInfo &pool_info)
 Set the input and output tensors. More...
 
void run (const Window &window, const ThreadInfo &info) override
 Execute the kernel on the passed window. More...
 
- Public Member Functions inherited from ICPPKernel
virtual ~ICPPKernel ()=default
 Default destructor. More...
 
virtual void run_nd (const Window &window, const ThreadInfo &info, const Window &thread_locator)
 legacy compatibility layer for implemantions which do not support thread_locator In these cases we simply narrow the interface down the legacy version More...
 
virtual void run_op (ITensorPack &tensors, const Window &window, const ThreadInfo &info)
 Execute the kernel on the passed window. More...
 
- 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...
 
virtual BorderSize border_size () const
 The size of the border for that kernel. More...
 
const Windowwindow () const
 The maximum window the kernel can be executed on. More...
 
bool is_window_configured () const
 Function to check if the embedded window of this kernel has been configured. More...
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *indices, const ITensorInfo *output, const PoolingLayerInfo &pool_info)
 Static function to check if given info will lead to a valid configuration of NEMaxUnpoolingLayerKernel. More...
 

Detailed Description

Interface for the pooling layer kernel.

Definition at line 34 of file NEMaxUnpoolingLayerKernel.h.

Constructor & Destructor Documentation

◆ NEMaxUnpoolingLayerKernel() [1/3]

Default constructor.

Definition at line 71 of file NEMaxUnpoolingLayerKernel.cpp.

Referenced by NEMaxUnpoolingLayerKernel::name().

72  : _func(nullptr), _input(nullptr), _output(nullptr), _indices(nullptr)
73 {
74 }

◆ NEMaxUnpoolingLayerKernel() [2/3]

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

◆ NEMaxUnpoolingLayerKernel() [3/3]

Allow instances of this class to be moved.

◆ ~NEMaxUnpoolingLayerKernel()

Default destructor.

Referenced by NEMaxUnpoolingLayerKernel::name().

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
const ITensor indices,
ITensor output,
const PoolingLayerInfo pool_info 
)

Set the input and output tensors.

Note
Output shape must be equal to the shape of the original input to pool.
Parameters
[in]inputSource tensor. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]indicesTensor containing the offset to store the input elements in the output tensor. NEPoolingLayer with indices should precede this function in order to properly reconstruct the output tensor. The tensor shape of this tensor has to be equal to the input tensor shape. Data type supported: U32.
[out]outputDestination tensor. Data types supported: Same as input.
[in]pool_infoContains pooling operation information described in PoolingLayerInfo.

Definition at line 76 of file NEMaxUnpoolingLayerKernel.cpp.

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::auto_init_if_empty(), ITensor::buffer(), arm_compute::calculate_max_window(), ICloneable< T >::clone(), arm_compute::misc::shape_calculator::compute_unpool_shape(), ITensorInfo::data_type(), arm_compute::execute_window_loop(), arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::test::validation::input, arm_compute::test::validation::output_shape, Iterator::ptr(), arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, ITensorInfo::strides_in_bytes(), and IKernel::window().

Referenced by NEMaxUnpoolingLayerKernel::name().

77 {
79  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info(), pool_info, indices->info()));
80 
81  _input = input;
82  _output = output;
83  _indices = indices;
84 
85  switch(input->info()->data_type())
86  {
87  case DataType::F32:
88  _func = &NEMaxUnpoolingLayerKernel::unpooling2<float>;
89  break;
90  case DataType::QASYMM8:
91  _func = &NEMaxUnpoolingLayerKernel::unpooling2<uint8_t>;
92  break;
94  _func = &NEMaxUnpoolingLayerKernel::unpooling2<int8_t>;
95  break;
96 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
97  case DataType::F16:
98  _func = &NEMaxUnpoolingLayerKernel::unpooling2<float16_t>;
99  break;
100 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
101  default:
102  break;
103  }
104  const TensorShape output_shape = compute_unpool_shape(*input->info(), pool_info);
105  auto_init_if_empty(*output->info(), input->info()->clone()->set_tensor_shape(output_shape));
106 
107  auto window = calculate_max_window(*input->info(), Steps());
108  INEKernel::configure(window);
109 }
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
1 channel, 1 F32 per channel
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:455
1 channel, 1 F16 per channel
TensorShape compute_unpool_shape(const ITensorInfo &input, PoolingLayerInfo pool_info)
Calculate the output unpool shape of a tensor.
quantized, asymmetric fixed-point 8-bit number unsigned
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...
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:157
quantized, asymmetric fixed-point 8-bit number signed

◆ name()

◆ operator=() [1/2]

NEMaxUnpoolingLayerKernel& operator= ( const NEMaxUnpoolingLayerKernel )
delete

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

Referenced by NEMaxUnpoolingLayerKernel::name().

◆ operator=() [2/2]

Allow instances of this class to be moved.

◆ run()

void run ( const Window window,
const ThreadInfo info 
)
overridevirtual

Execute the kernel on the passed window.

Warning
If is_parallelisable() returns false then the passed window must be equal to window()
Note
The window has to be a region within the window returned by the window() method
The width of the window has to be a multiple of num_elems_processed_per_iteration().
Parameters
[in]windowRegion on which to execute the kernel. (Must be a region of the window returned by window())
[in]infoInfo about executing thread and CPU.

Reimplemented from ICPPKernel.

Definition at line 133 of file NEMaxUnpoolingLayerKernel.cpp.

References ARM_COMPUTE_ERROR_ON, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, and IKernel::window().

Referenced by NEMaxUnpoolingLayerKernel::name().

134 {
138  ARM_COMPUTE_ERROR_ON(_func == nullptr);
139  // Run function
140  (this->*_func)(window);
141 }
const Window & window() const
The maximum window the kernel can be executed on.
Definition: IKernel.cpp:28
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:152
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:915
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:201

◆ validate()

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

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

Parameters
[in]inputSource tensor info. Data types supported: QASYMM8/QASYMM8_SIGNED/F16/F32.
[in]outputDestination tensor info. Data types supported: Same as input.
[in]indicesTensor info of the indices of the maximal values. Data type supported: U32.
[in]pool_infoContains pooling operation information described in PoolingLayerInfo.
Returns
a status

Definition at line 126 of file NEMaxUnpoolingLayerKernel.cpp.

References ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR, and ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by NEMaxUnpoolingLayerKernel::name(), and NEMaxUnpoolingLayer::validate().

127 {
128  ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(input, indices, output);
129  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output, pool_info, indices));
130  return Status{};
131 }
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
Definition: Error.h:204
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Definition: Validate.h:159

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