Compute Library
 19.08
NEQuantizationLayerKernel Class Reference

Interface for the quantization layer kernel. More...

#include <NEQuantizationLayerKernel.h>

Collaboration diagram for NEQuantizationLayerKernel:
[legend]

Public Member Functions

const char * name () const override
 Name of the kernel. More...
 
 NEQuantizationLayerKernel ()
 Default constructor. More...
 
 NEQuantizationLayerKernel (const NEQuantizationLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEQuantizationLayerKerneloperator= (const NEQuantizationLayerKernel &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEQuantizationLayerKernel (NEQuantizationLayerKernel &&)=default
 Default Move Constructor. More...
 
NEQuantizationLayerKerneloperator= (NEQuantizationLayerKernel &&)=default
 Default move assignment operator. More...
 
 ~NEQuantizationLayerKernel ()=default
 Default destructor. More...
 
void configure (const ITensor *input, ITensor *output)
 Set the input, output. 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...
 
- 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...
 

Static Public Member Functions

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

Detailed Description

Interface for the quantization layer kernel.

Note
The implementation supports only 3D input tensors

Definition at line 38 of file NEQuantizationLayerKernel.h.

Constructor & Destructor Documentation

◆ NEQuantizationLayerKernel() [1/3]

Default constructor.

Definition at line 73 of file NEQuantizationLayerKernel.cpp.

74  : _input(nullptr), _output(nullptr)
75 {
76 }

◆ NEQuantizationLayerKernel() [2/3]

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

◆ NEQuantizationLayerKernel() [3/3]

Default Move Constructor.

◆ ~NEQuantizationLayerKernel()

Default destructor.

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
ITensor output 
)

Set the input, output.

Parameters
[in]inputSource tensor. The dimensions over the third will be interpreted as batches. Data types supported: F32/F16.
[out]outputDestination tensor with the same dimensions of input. Data types supported: QASYMM8.

Definition at line 78 of file NEQuantizationLayerKernel.cpp.

79 {
80  ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
81  ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info()));
82 
83  _input = input;
84  _output = output;
85 
86  // Configure kernel window
87  Window win_config = calculate_max_window(*input->info(), Steps());
88 
89  Coordinates coord;
90  coord.set_num_dimensions(output->info()->num_dimensions());
91  output->info()->set_valid_region(ValidRegion(coord, output->info()->tensor_shape()));
92 
93  INEKernel::configure(win_config);
94 }
virtual size_t num_dimensions() const =0
The number of dimensions of the tensor (rank)
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Definition: Error.h:327
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
virtual void set_valid_region(const ValidRegion &valid_region)=0
Set the valid region of the tensor.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Class to describe a number of elements in each dimension.
Definition: Steps.h:40
Coordinates of an item.
Definition: Coordinates.h:37
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Definition: Validate.h:161
void set_num_dimensions(size_t num_dimensions)
Set number of dimensions.
Definition: Dimensions.h:128
Container for valid region of a window.
Definition: Types.h:174
Describe a multidimensional execution window.
Definition: Window.h:39

References ARM_COMPUTE_ERROR_ON_NULLPTR, ARM_COMPUTE_ERROR_THROW_ON, arm_compute::calculate_max_window(), ITensor::info(), ITensorInfo::num_dimensions(), Dimensions< T >::set_num_dimensions(), ITensorInfo::set_valid_region(), and ITensorInfo::tensor_shape().

◆ name()

const char* name ( ) const
inlineoverridevirtual

Name of the kernel.

Returns
Kernel name

Implements ICPPKernel.

Definition at line 41 of file NEQuantizationLayerKernel.h.

42  {
43  return "NEQuantizationLayerKernel";
44  }

◆ operator=() [1/2]

NEQuantizationLayerKernel& operator= ( const NEQuantizationLayerKernel )
delete

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

◆ operator=() [2/2]

Default move assignment operator.

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

Implements ICPPKernel.

Definition at line 142 of file NEQuantizationLayerKernel.cpp.

143 {
147 
148  const QuantizationInfo &qinfo = _output->info()->quantization_info();
149 
150  switch(_input->info()->data_type())
151  {
152  case DataType::F32:
153  NEQuantizationLayerKernel::quantize<float>(window, qinfo);
154  break;
155 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
156  case DataType::F16:
157  NEQuantizationLayerKernel::quantize<float16_t>(window, qinfo);
158  break;
159 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
160  default:
161  ARM_COMPUTE_ERROR("Unsupported data type.");
162  }
163 }
#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 DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
1 channel, 1 F16 per channel
Quantization information.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Definition: Error.h:160
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.
const QuantizationInfo qinfo
Definition: Im2Col.cpp:150
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
Definition: Validate.h:205
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Definition: Validate.h:940

References ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW, ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL, ARM_COMPUTE_UNUSED, ITensorInfo::data_type(), arm_compute::F16, arm_compute::F32, ITensor::info(), arm_compute::test::validation::info, arm_compute::test::validation::qinfo, ITensorInfo::quantization_info(), and IKernel::window().

◆ validate()

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

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

Parameters
[in]inputInput tensor info. Data types supported: F32/F16.
[in]outputOutput tensor info. Data types supported: QASYMM8.
Returns
a status

Definition at line 96 of file NEQuantizationLayerKernel.cpp.

97 {
98  ARM_COMPUTE_RETURN_ON_ERROR(validate_arguments(input, output));
99 
100  return Status{};
101 }
#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

References ARM_COMPUTE_RETURN_ON_ERROR.

Referenced by NEQuantizationLayer::validate().


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