Compute Library
 21.02
NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint Class Reference

Basic function to execute NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint on Neon. More...

#include <NEGEMMLowpOutputStage.h>

Collaboration diagram for NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint:
[legend]

Public Member Functions

 NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint ()=default
 Constructor. More...
 
 NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint (const NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointoperator= (const NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint (NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointoperator= (NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint &&)=delete
 Prevent instances of this class from being moved (As this class contains non movable objects) More...
 
 ~NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint ()
 Default destructor. More...
 
void configure (const ITensor *input, const ITensor *bias, ITensor *output, int result_fixedpoint_multiplier, int result_shift, int min=std::numeric_limits< int32_t >::lowest(), int max=std::numeric_limits< int32_t >::max())
 Initialise the kernel's inputs, output. More...
 
- Public Member Functions inherited from INESimpleFunctionNoBorder
 INESimpleFunctionNoBorder (IRuntimeContext *ctx=nullptr)
 Constructor. More...
 
 INESimpleFunctionNoBorder (const INESimpleFunctionNoBorder &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
 INESimpleFunctionNoBorder (INESimpleFunctionNoBorder &&)=default
 Default move constructor. More...
 
INESimpleFunctionNoBorderoperator= (const INESimpleFunctionNoBorder &)=delete
 Prevent instances of this class from being copied (As this class contains pointers) More...
 
INESimpleFunctionNoBorderoperator= (INESimpleFunctionNoBorder &&)=default
 Default move assignment operator. More...
 
 ~INESimpleFunctionNoBorder ()
 Default destructor. 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 *bias, const ITensorInfo *output, int min=std::numeric_limits< int32_t >::lowest(), int max=std::numeric_limits< int32_t >::max())
 Static function to check if given info will lead to a valid configuration of NEGEMMLowpQuantizeDownInt32ToUint8ScaleByFixedPoint. More...
 

Detailed Description

Basic function to execute NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint on Neon.

NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint depends on 2 parameters:

result_fixedpoint_multiplier, result_shift

The final result is:

(FixedPointMul(input[i][k], result_fixedpoint_multiplier) >> result_shift)

where FixedPointMul(x, y) is the nearest integer to the following mathematical expression, evaluated without overflow or intermediate rounding:

(x * y) / 2^31

For more information: https://github.com/google/gemmlowp/blob/master/public/output_stages.h#L68

In case the bias tensor is provided, the final result is:

((FixedPointMul(input[i][k] + bias[k], result_fixedpoint_multiplier)) >> result_shift) + result_offset_after_shift

This function calls the following Neon kernels:

  1. NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel
Note
The function accepts also 2 optional input arguments (min and max) which can be used to implement "rectified linear unit" activation functions after the result is shifted right by result_shift

Definition at line 215 of file NEGEMMLowpOutputStage.h.

Constructor & Destructor Documentation

◆ NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint() [1/3]

◆ NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint() [2/3]

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

◆ NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint() [3/3]

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ ~NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPoint()

Member Function Documentation

◆ configure()

void configure ( const ITensor input,
const ITensor bias,
ITensor output,
int  result_fixedpoint_multiplier,
int  result_shift,
int  min = std::numeric_limits<int32_t>::lowest(),
int  max = std::numeric_limits<int32_t>::max() 
)

Initialise the kernel's inputs, output.

Parameters
[in]inputInput tensor. Data type supported: S32
[in]biasBiases tensor. Only shared biases supported and it can be a nullptr if the biases addition is not required. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as input.
[out]outputOutput tensor. Data type supported: Data type supported: QSYMM16
[in]result_fixedpoint_multiplierFixed point value to be multiplied to each element of the input matrix when once the result_offset has been add
[in]result_shiftNumber of bits to shift right the result after the fixed point multiplication
[in]min(Optional) Min value used to saturate down the output result before converting back to QSYMM16. Defaults to the minimum possible 32-bit signed integer.
[in]max(Optional) Max value used to saturate up the output result before converting back to QSYMM16. Along with min, this value can be used to implement "rectified linear unit" activation functions. Defaults to the maximum possible 32-bit signed integer.

Definition at line 67 of file NEGEMMLowpOutputStage.cpp.

Referenced by NELSTMLayerQuantized::configure().

68 {
69  auto k = std::make_unique<NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel>();
70  k->configure(input, bias, output, result_fixedpoint_multiplier, result_shift, min, max);
71  _kernel = std::move(k);
72 }

◆ operator=() [1/2]

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

◆ operator=() [2/2]

Prevent instances of this class from being moved (As this class contains non movable objects)

◆ validate()

Status validate ( const ITensorInfo input,
const ITensorInfo bias,
const ITensorInfo output,
int  min = std::numeric_limits<int32_t>::lowest(),
int  max = std::numeric_limits<int32_t>::max() 
)
static

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

Parameters
[in]inputInput tensor info. It is the output of NEGEMMLowpMatrixMultiplyCore function. Data type supported: S32
[in]biasBiases tensor info. Only shared biases supported and it can be a nullptr if the addition of biases is not required. Biases are 1D tensor with dimensions [OFM]. Data type supported: Same as input.
[in]outputOutput tensor info. Data type supported: Data type supported: QSYMM16
[in]min(Optional) Min value used to saturate down the output result before converting back to QSYMM16. Defaults to the minimum possible 32-bit signed integer.
[in]max(Optional) Max value used to saturate up the output result before converting back to QSYMM16, Along with min, this value can be used to implement "rectified linear unit" activation functions. Defaults to the maximum possible 32-bit signed integer.
Returns
a status

Definition at line 74 of file NEGEMMLowpOutputStage.cpp.

References NEGEMMLowpQuantizeDownInt32ToInt16ScaleByFixedPointKernel::validate(), and NEGEMMLowpOutputStage::~NEGEMMLowpOutputStage().

Referenced by arm_compute::test::validation::DATA_TEST_CASE(), and NELSTMLayerQuantized::validate().

75 {
77 }
static Status validate(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, int min=0, int max=0)
Static function to check if given info will lead to a valid configuration of NEGEMMLowpQuantizeDownIn...

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