Compute Library
 21.02
Qasymm8QuantizationHelper< QUANTIZED_TYPE > Struct Template Reference

#include <QuantizationInfo.h>

Static Public Member Functions

static QUANTIZED_TYPE quantize (float value, const UniformQuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
 Quantize a value given a 8-bit asymmetric quantization scheme. More...
 
static QUANTIZED_TYPE quantize (float value, const QuantizationInfo &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
 Quantize a value given a 8-bit asymmetric quantization scheme. More...
 
static float dequantize (QUANTIZED_TYPE value, const UniformQuantizationInfo &qinfo)
 Dequantize a value given a 8-bit asymmetric quantization scheme. More...
 
static float dequantize (QUANTIZED_TYPE value, const QuantizationInfo &qinfo)
 Dequantize a value given a 8-bit asymmetric quantization scheme. More...
 

Detailed Description

template<typename QUANTIZED_TYPE = uint8_t>
struct arm_compute::Qasymm8QuantizationHelper< QUANTIZED_TYPE >

Definition at line 211 of file QuantizationInfo.h.

Member Function Documentation

◆ dequantize() [1/2]

static float dequantize ( QUANTIZED_TYPE  value,
const UniformQuantizationInfo qinfo 
)
inlinestatic

Dequantize a value given a 8-bit asymmetric quantization scheme.

Parameters
[in]valueValue to dequantize
[in]qinfoQuantization information to use for dequantizing
Returns
Dequantized value

Definition at line 255 of file QuantizationInfo.h.

256  {
257  return (static_cast<int>(value) - qinfo.offset) * qinfo.scale;
258  }
const std::vector< int32_t > & offset() const
Offset vector accessor.
const std::vector< float > & scale() const
Scale vector accessor.
const QuantizationInfo qinfo
Definition: Im2Col.cpp:155

◆ dequantize() [2/2]

static float dequantize ( QUANTIZED_TYPE  value,
const QuantizationInfo qinfo 
)
inlinestatic

Dequantize a value given a 8-bit asymmetric quantization scheme.

Parameters
[in]valueValue to dequantize
[in]qinfoQuantization information to use for dequantizing
Returns
Dequantized value

Definition at line 267 of file QuantizationInfo.h.

268  {
269  const UniformQuantizationInfo uqinfo = qinfo.uniform();
270  return (static_cast<int>(value) - uqinfo.offset) * uqinfo.scale;
271  }
UniformQuantizationInfo uniform() const
Return per layer quantization info.
const QuantizationInfo qinfo
Definition: Im2Col.cpp:155

◆ quantize() [1/2]

static QUANTIZED_TYPE quantize ( float  value,
const UniformQuantizationInfo qinfo,
RoundingPolicy  rounding_policy = RoundingPolicy::TO_NEAREST_UP 
)
inlinestatic

Quantize a value given a 8-bit asymmetric quantization scheme.

Parameters
[in]valueValue to quantize
[in]qinfoQuantization information to use for quantizing
[in]rounding_policy(Optional) Rounding policy to use. Default: nearest up
Returns
Quantized value

Definition at line 225 of file QuantizationInfo.h.

Referenced by NEQuantizationLayerKernel::validate().

226  {
228  const int quantized = arm_compute::round(value / qinfo.scale, rounding_policy) + qinfo.offset;
229  return static_cast<QUANTIZED_TYPE>(arm_compute::utility::clamp<decltype(quantized), QUANTIZED_TYPE>(quantized));
230  }
const std::vector< int32_t > & offset() const
Offset vector accessor.
#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
const std::vector< float > & scale() const
Scale vector accessor.
int round(float x, RoundingPolicy rounding_policy)
Return a rounded value of x.
Definition: Rounding.cpp:35
const QuantizationInfo qinfo
Definition: Im2Col.cpp:155

◆ quantize() [2/2]

static QUANTIZED_TYPE quantize ( float  value,
const QuantizationInfo qinfo,
RoundingPolicy  rounding_policy = RoundingPolicy::TO_NEAREST_UP 
)
inlinestatic

Quantize a value given a 8-bit asymmetric quantization scheme.

Parameters
[in]valueValue to quantize
[in]qinfoQuantization information to use for quantizing
[in]rounding_policy(Optional) Rounding policy to use. Default: nearest up
Returns
Quantized value

Definition at line 240 of file QuantizationInfo.h.

241  {
242  const UniformQuantizationInfo uqinfo = qinfo.uniform();
243  ARM_COMPUTE_ERROR_ON(uqinfo.scale == 0);
244  const int quantized = arm_compute::round(value / uqinfo.scale, rounding_policy) + uqinfo.offset;
245  return static_cast<QUANTIZED_TYPE>(arm_compute::utility::clamp<decltype(quantized), QUANTIZED_TYPE>(quantized));
246  }
#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
UniformQuantizationInfo uniform() const
Return per layer quantization info.
int round(float x, RoundingPolicy rounding_policy)
Return a rounded value of x.
Definition: Rounding.cpp:35
const QuantizationInfo qinfo
Definition: Im2Col.cpp:155

The documentation for this struct was generated from the following file: