24.02.1
|
Functions | |
Status | calculate_quantized_multiplier (float multiplier, int32_t *quant_multiplier, int32_t *shift, bool ignore_epsilon=false) |
Calculate quantized representation of multiplier. More... | |
Status | calculate_quantized_multiplier_less_than_one (float multiplier, int32_t *quant_multiplier, int32_t *right_shift, bool ignore_epsilon=false) |
Calculate quantized representation of multiplier with value less than one. More... | |
Status | calculate_quantized_multiplier_greater_than_one (float multiplier, int32_t *quantized_multiplier, int32_t *left_shift) |
Calculate quantized representation of multiplier having value greater than one. More... | |
Status | calculate_quantized_multipliers (const QuantizationInfo &iq_info, const QuantizationInfo &wq_info, const QuantizationInfo &oq_info, GEMMLowpOutputStageInfo &stage_info) |
Calculate quantized representation of per-channel multipliers. More... | |
std::pair< int, int > | get_min_max_values_from_quantized_data_type (DataType data_type) |
Get minimum and maximum values for the input quantized data type. More... | |
void | compute_quantized_multipliers_and_shifts (const ITensorInfo *input, const ITensorInfo *weights, const ITensorInfo *output, int32_t *output_multipliers_ptr, int32_t *output_shifts_ptr) |
Compute quantized per-channel multipliers and shifts. More... | |
int32_t | rounding_divide_by_pow2 (int32_t x, int exponent) |
Round to the nearest division by a power-of-two using exponent, copied from NEMath. More... | |
int32_t | saturating_rounding_doubling_highmul (int32_t a, int32_t b) |
Compute multiplication of two integers. More... | |
int32_t | multiply_by_quantized_multiplier (int32_t input, int32_t qmul, int32_t shift) |
Compute the value multiplied by given quantized multiplier and shift. More... | |
int32_t | saturating_rounding_multiply_by_pow2 (int32_t exponent, int32_t v) |
Compute the value multiplied the power-of-two. More... | |
void | get_invsqrt_quantized_multiplier_exp (int32_t input, int32_t reverse_shift, int32_t &output_inv_sqrt, int32_t &output_shift) |
Compute quantized multiplier and shift for the inverse square root of input. More... | |
std::tuple< int32_t, int32_t > | get_quantized_asymmetric_output_min_max (const QuantizationInfo &q_info, const ActivationLayerInfo &act_info, DataType data_type) |
Get minimum and maximum output of the activation function after quantization. More... | |
Variables | |
constexpr int64_t | fixed_point_one_Q0 = (1LL << 31) |
constexpr float | epsilon = 0.00001f |
Status calculate_quantized_multiplier | ( | float | multiplier, |
int32_t * | quant_multiplier, | ||
int32_t * | shift, | ||
bool | ignore_epsilon = false |
||
) |
Calculate quantized representation of multiplier.
[in] | multiplier | Real multiplier. |
[out] | quant_multiplier | Integer multiplier. |
[out] | shift | bit shift. A negative value indicates a left shift, while a positive value indicates a right shift |
[in] | ignore_epsilon | When true, ignore pre-defined epsilon value. Defaults to false |
Definition at line 43 of file AsymmHelpers.cpp.
References calculate_quantized_multiplier_greater_than_one(), and calculate_quantized_multiplier_less_than_one().
Referenced by calculate_quantized_multipliers(), compute_quantized_multipliers_and_shifts(), ClTransposedConvolutionKernel::configure(), ClMatMulLowpNativeMMULKernel::configure(), ClMatMulLowpNativeKernel::configure(), NEQLSTMLayerNormalizationKernel::configure(), CLQLSTMLayerNormalizationKernel::configure(), ClDirectConv2dKernel::configure(), ClDirectConv3dKernel::configure(), CLDepthwiseConvolutionLayerNativeKernel::configure(), NELSTMLayerQuantized::configure(), NEQLSTMLayer::configure(), CLLSTMLayerQuantized::configure(), CLQLSTMLayer::configure(), arm_compute::cpu::directconv3d_quantized_neon_ndhwc(), arm_compute::test::validation::reference::qlstm_layer_normalization(), arm_compute::cpu::run_depthwise_quanitized8bit(), CpuPool2dAssemblyWrapperKernel::validate(), NELSTMLayerQuantized::validate(), CLLSTMLayerQuantized::validate(), NEQLSTMLayer::validate(), and CLQLSTMLayer::validate().
Status calculate_quantized_multiplier_greater_than_one | ( | float | multiplier, |
int32_t * | quantized_multiplier, | ||
int32_t * | left_shift | ||
) |
Calculate quantized representation of multiplier having value greater than one.
[in] | multiplier | Real multiplier. |
[out] | quantized_multiplier | Integer multiplier. |
[out] | left_shift | Left bit shift. |
Definition at line 94 of file AsymmHelpers.cpp.
References ARM_COMPUTE_RETURN_ERROR_ON, fixed_point_one_Q0, and arm_compute::support::cpp11::round().
Referenced by calculate_quantized_multiplier().
Status calculate_quantized_multiplier_less_than_one | ( | float | multiplier, |
int32_t * | quant_multiplier, | ||
int32_t * | right_shift, | ||
bool | ignore_epsilon = false |
||
) |
Calculate quantized representation of multiplier with value less than one.
[in] | multiplier | Real multiplier. |
[out] | quant_multiplier | Integer multiplier. |
[out] | right_shift | Right bit shift. |
[in] | ignore_epsilon | When true, ignore pre-defined epsilon value. Defaults to false |
Definition at line 57 of file AsymmHelpers.cpp.
References ARM_COMPUTE_RETURN_ERROR_ON, epsilon, fixed_point_one_Q0, and arm_compute::support::cpp11::round().
Referenced by calculate_quantized_multiplier(), and main().
arm_compute::Status calculate_quantized_multipliers | ( | const QuantizationInfo & | iq_info, |
const QuantizationInfo & | wq_info, | ||
const QuantizationInfo & | oq_info, | ||
GEMMLowpOutputStageInfo & | stage_info | ||
) |
Calculate quantized representation of per-channel multipliers.
[in] | iq_info | Input quantization info. |
[in] | wq_info | Weights quantization info. |
[in] | oq_info | Output quantization info. |
[in,out] | stage_info | GemmLowp output stage info |
Definition at line 117 of file AsymmHelpers.cpp.
References ARM_COMPUTE_RETURN_ERROR_ON, ARM_COMPUTE_RETURN_ON_ERROR, calculate_quantized_multiplier(), GEMMLowpOutputStageInfo::gemmlowp_multiplier, GEMMLowpOutputStageInfo::gemmlowp_multipliers, GEMMLowpOutputStageInfo::gemmlowp_shift, GEMMLowpOutputStageInfo::gemmlowp_shifts, and QuantizationInfo::scale().
void compute_quantized_multipliers_and_shifts | ( | const ITensorInfo * | input, |
const ITensorInfo * | weights, | ||
const ITensorInfo * | output, | ||
int32_t * | output_multipliers_ptr, | ||
int32_t * | output_shifts_ptr | ||
) |
Compute quantized per-channel multipliers and shifts.
As many multipliers and shifts as output channels are computed. If weights are not quantized per-channel, multipliers and shifts will end up being the same for each channel.
[in] | input | Input tensor info. |
[in] | weights | Weights tensor info. |
[in] | output | Output tensor info. |
[out] | output_multipliers_ptr | Pointer to the buffer where to store per-channel multipliers. |
[out] | output_shifts_ptr | Pointer to the buffer where to store per-channel shifts. |
Definition at line 223 of file AsymmHelpers.cpp.
References calculate_quantized_multiplier(), arm_compute::test::validation::input, ITensorInfo::quantization_info(), UniformQuantizationInfo::scale, QuantizationInfo::scale(), and QuantizationInfo::uniform().
Referenced by ClGemmConv2d::configure(), CLDepthwiseConvolutionLayer::prepare(), and ClGemmConv2d::validate().
void get_invsqrt_quantized_multiplier_exp | ( | int32_t | input, |
int32_t | reverse_shift, | ||
int32_t & | output_inv_sqrt, | ||
int32_t & | output_shift | ||
) |
Compute quantized multiplier and shift for the inverse square root of input.
Using 3-bit fixed point and 5 iteration of Newton-Raphson method.
[in] | input | Input to use |
[in] | reverse_shift | -1 to reverse the shift direction |
[out] | output_inv_sqrt | Quantized multiplier for inverse square root |
[out] | output_shift | Shift for inverse square root |
Definition at line 300 of file AsymmHelpers.cpp.
References ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::b, arm_compute::test::validation::input, rounding_divide_by_pow2(), saturating_rounding_doubling_highmul(), and saturating_rounding_multiply_by_pow2().
Referenced by arm_compute::test::validation::reference::qlstm_layer_normalization().
std::pair< int, int > get_min_max_values_from_quantized_data_type | ( | DataType | data_type | ) |
Get minimum and maximum values for the input quantized data type.
Definition at line 154 of file AsymmHelpers.cpp.
References ARM_COMPUTE_ERROR, arm_compute::test::validation::data_type, arm_compute::QASYMM16, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::QSYMM16, and arm_compute::QSYMM8.
Referenced by ClQuantizeKernel::configure(), ClGemmLowpQuantizeDownInt32ScaleByFixedPointKernel::configure(), ClGemmLowpQuantizeDownInt32ScaleKernel::configure(), CLQLSTMLayerNormalizationKernel::configure(), and CpuGemmLowpQuantizeDownInt32ScaleKernel::configure().
std::tuple< int32_t, int32_t > get_quantized_asymmetric_output_min_max | ( | const QuantizationInfo & | q_info, |
const ActivationLayerInfo & | act_info, | ||
DataType | data_type | ||
) |
Get minimum and maximum output of the activation function after quantization.
Only ReLU, upper bounded ReLU and lower+upper bounded ReLU are supported.
[in] | q_info | Output quantization info. |
[in] | act_info | Activation function information. |
[in] | data_type | Output data type (either QASYMM8 or QASYMM8_SIGNED). |
Definition at line 183 of file AsymmHelpers.cpp.
References arm_compute::test::validation::act_info, ARM_COMPUTE_ERROR, ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::data_type, arm_compute::get_min_max(), UniformQuantizationInfo::offset, arm_compute::QASYMM8, arm_compute::QASYMM8_SIGNED, arm_compute::quantize_qasymm8(), arm_compute::quantize_qasymm8_signed(), and QuantizationInfo::uniform().
int32_t multiply_by_quantized_multiplier | ( | int32_t | input, |
int32_t | qmul, | ||
int32_t | shift | ||
) |
Compute the value multiplied by given quantized multiplier and shift.
[in] | input | Target value to multiply. |
[in] | qmul | Quantized multipler |
[in] | shift | Left bit shift |
Definition at line 267 of file AsymmHelpers.cpp.
References arm_compute::test::validation::input, rounding_divide_by_pow2(), and saturating_rounding_doubling_highmul().
Referenced by arm_compute::test::validation::reference::qlstm_layer_normalization().
|
inline |
Round to the nearest division by a power-of-two using exponent, copied from NEMath.
[in] | x | Element to divide. |
[in] | exponent | Integer value used to round to nearest division by a power-of-two |
Definition at line 260 of file AsymmHelpers.cpp.
Referenced by get_invsqrt_quantized_multiplier_exp(), multiply_by_quantized_multiplier(), and saturating_rounding_multiply_by_pow2().
int32_t saturating_rounding_doubling_highmul | ( | int32_t | a, |
int32_t | b | ||
) |
Compute multiplication of two integers.
[in] | a | One integer to multiply |
[in] | b | Another integer to multiply |
Definition at line 247 of file AsymmHelpers.cpp.
References arm_compute::test::validation::b, and arm_compute::support::cpp11::signbit().
Referenced by get_invsqrt_quantized_multiplier_exp(), and multiply_by_quantized_multiplier().
int32_t saturating_rounding_multiply_by_pow2 | ( | int32_t | exponent, |
int32_t | v | ||
) |
Compute the value multiplied the power-of-two.
[in] | exponent | Exponent used to calculate power-of-two |
[in] | v | Target value to multiply |
Definition at line 274 of file AsymmHelpers.cpp.
References rounding_divide_by_pow2().
Referenced by get_invsqrt_quantized_multiplier_exp().
|
constexpr |
Definition at line 41 of file AsymmHelpers.cpp.
Referenced by GraphBuilder::add_batch_normalization_node(), GraphBuilder::add_l2_normalize_node(), arm_compute::test::validation::reference::batch_normalization_layer(), arm_compute::cpu::batch_normalization_nchw(), calculate_quantized_multiplier_less_than_one(), CLMeanStdDevNormalizationKernel::configure(), CLMeanStdDevNormalizationLayer::configure(), CLL2NormalizeLayerKernel::configure(), CLFuseBatchNormalizationKernel::configure(), NEMeanStdDevNormalizationKernel::configure(), CLBatchNormalizationLayerKernel::configure(), NEMeanStdDevNormalizationLayer::configure(), NEFuseBatchNormalizationKernel::configure(), FusedDepthwiseConvolutionBatchNormalizationFunction< TargetInfo, FusedLayerTypes >::configure(), NEBatchNormalizationLayerKernel::configure(), FusedConvolutionBatchNormalizationFunction< TargetInfo, FusedLayerTypes >::configure(), NEFuseBatchNormalization::configure(), NEL2NormalizeLayer::configure(), NEInstanceNormalizationLayer::configure(), CLFuseBatchNormalization::configure(), CLL2NormalizeLayer::configure(), NEBatchNormalizationLayer::configure(), CLBatchNormalizationLayer::configure(), CLInstanceNormalizationLayer::configure(), arm_compute::graph::backends::detail::create_batch_normalization_layer(), arm_compute::graph::backends::detail::create_fused_convolution_batch_normalization_layer(), arm_compute::graph::backends::detail::create_fused_depthwise_convolution_batch_normalization_layer(), arm_compute::graph::backends::detail::create_l2_normalize_layer(), AssetsLibrary::fill_boxes(), arm_compute::cpu::fp32_batch_normalization_nchw_non_fused(), arm_compute::cpu::fp32_batch_normalization_nchw_non_fused_brelu(), arm_compute::cpu::fp32_batch_normalization_nchw_non_fused_lubrelu(), arm_compute::cpu::fp32_batch_normalization_nchw_non_fused_relu(), arm_compute::cpu::fp32_neon_batch_normalization(), arm_compute::test::validation::reference::fuse_batch_normalization_conv_layer(), arm_compute::test::validation::reference::fuse_batch_normalization_dwc_layer(), arm_compute::graph::detail::fuse_convolution_with_batch_normalization(), arm_compute::graph::detail::fuse_depthwise_convolution_with_batch_normalization(), arm_compute::cpu::fused_batch_normalization_conv(), arm_compute::cpu::fused_batch_normalization_conv_f32(), arm_compute::cpu::fused_batch_normalization_dwc_nchw(), arm_compute::cpu::fused_batch_normalization_dwc_nchw_f32(), arm_compute::cpu::fused_batch_normalization_dwc_nhwc(), arm_compute::cpu::fused_batch_normalization_dwc_nhwc_f32(), arm_compute::test::validation::reference::instance_normalization(), arm_compute::cpu::instance_normalization_nchw(), arm_compute::helpers::float_ops::is_one(), arm_compute::helpers::float_ops::is_zero(), arm_compute::test::validation::reference::l2_normalize(), arm_compute::cpu::l2_normalize_x(), arm_compute::cpu::l2_normalize_yz(), arm_compute::test::validation::reference::mean_std_normalization_layer(), arm_compute::cpu::mean_stddev_normalization(), arm_compute::cpu::neon_fp32_instancenorm(), arm_compute::cpu::neon_fp32_l2_normalize_x(), arm_compute::cpu::neon_fp32_l2_normalize_yz(), arm_compute::cpu::neon_fp32_meanstddevnorm(), arm_compute::cpu::neon_qasymm8_meanstddevnorm(), compare< RelativeTolerance< U > >::operator bool(), RangedUniformDistribution< T >::RangedUniformDistribution(), arm_compute::test::round_half_even(), arm_compute::utils::rounding::round_half_even(), NEMeanStdDevNormalizationKernel::validate(), NEMeanStdDevNormalizationLayer::validate(), CLMeanStdDevNormalizationLayer::validate(), CLMeanStdDevNormalizationKernel::validate(), NEL2NormalizeLayer::validate(), CLL2NormalizeLayerKernel::validate(), NEBatchNormalizationLayerKernel::validate(), NEFuseBatchNormalizationKernel::validate(), CLL2NormalizeLayer::validate(), NEFuseBatchNormalization::validate(), NEBatchNormalizationLayer::validate(), CLBatchNormalizationLayerKernel::validate(), CLFuseBatchNormalizationKernel::validate(), CLInstanceNormalizationLayer::validate(), CLBatchNormalizationLayer::validate(), CLFuseBatchNormalization::validate(), and arm_compute::graph::backends::detail::validate_l2_normalize_layer().
|
constexpr |
Definition at line 40 of file AsymmHelpers.cpp.
Referenced by calculate_quantized_multiplier_greater_than_one(), and calculate_quantized_multiplier_less_than_one().