Compute Library
 21.02
helpers_asymm.h File Reference
#include "helpers.h"

Go to the source code of this file.

Macros

#define CONVERT_DOWN_RTE_STR(x, type)   (convert_##type##_rte((x)))
 Convert the given vector with round to nearest even rounding mode. More...
 
#define CONVERT_DOWN_RTE(x, type)   CONVERT_DOWN_RTE_STR(x, type)
 
#define QUANTIZE_IMPL(type, size)
 Quantize a vector of values from floating-point. More...
 
#define DEQUANTIZE_IMPL(type, size)
 Dequantize a vector of values to floating-point. More...
 
#define ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(size)
 Correctly-rounded-to-nearest division by a power-of-two. More...
 
#define ASYMM_MULT_IMPL(size)
 Product of two numbers, interpreting them as fixed-point values in the interval [-1, 1), rounding to the nearest value, and saturating -1 * -1 to the maximum value. More...
 
#define ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(size)
 Calculates \( exp(x) \) for x in [-1/4, 0). More...
 
#define ASYMM_SELECT_USING_MASK_IMPL(size)
 Each bit of the result is set to the corresponding bit of either then_val or else_val depending on whether the corresponding bit of if_mask is set. More...
 
#define ASYMM_MASK_IF_ZERO_IMPL(size)
 For each element of input vector, the corresponding bits of the result item are set if the input item is zero. More...
 
#define ASYMM_MASK_IF_NON_ZERO_IMPL(size)
 For each element of input vector, the corresponding bits of the result item are set if the input item is non-zero. More...
 
#define EXP_BARREL_SHIFTER_IMPL(size)
 
#define ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(size)
 Calculates \( exp(x) \) for x < 0. More...
 
#define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(size)
 Calculates the product of a integer value by a power of two, with either a positive exponent (equivalent to an arithmetic left shift, saturating) or a negative exponent (equivalent to an arithmetic right shift, rounding to nearest). More...
 
#define ASYMM_ROUNDING_HALF_SUM_IMPL(size)
 Calculates (a+b)/2, rounded to the nearest integer. More...
 
#define ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(size)
 Calculates \( 1 / (1 + x) \) for x in (0, 1). More...
 
#define ASYMM_RESCALE_IMPL(size)
 Considering the integer value as fixed-point, change the number of integer bits and update value accordingly. More...
 
#define QUANTIZE_STR(input, offset, scale, type, size)   quantize_##type##size(input, offset, scale)
 
#define QUANTIZE(input, offset, scale, type, size)   QUANTIZE_STR(input, offset, scale, type, size)
 
#define DEQUANTIZE_STR(input, offset, scale, type, size)   dequantize_##type##size(input, offset, scale)
 
#define DEQUANTIZE(input, offset, scale, type, size)   DEQUANTIZE_STR(input, offset, scale, type, size)
 
#define ASYMM_ROUNDING_DIVIDE_BY_POW2_STR(x, exponent, size)   asymm_rounding_divide_by_POW2_##size(x, exponent)
 
#define ASYMM_ROUNDING_DIVIDE_BY_POW2(x, exponent, size)   ASYMM_ROUNDING_DIVIDE_BY_POW2_STR(x, exponent, size)
 
#define ASYMM_MULT_STR(a, b, size)   asymm_mult##size(a, b)
 
#define ASYMM_MULT(a, b, size)   ASYMM_MULT_STR(a, b, size)
 
#define ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE(x, quantized_multiplier, left_shift, size)   ASYMM_MULT(x *((VEC_DATA_TYPE(int, size))(1) << (-left_shift)), quantized_multiplier, size)
 
#define ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE(x, quantized_multiplier, right_shift, size)   ASYMM_ROUNDING_DIVIDE_BY_POW2(ASYMM_MULT(x, quantized_multiplier, size), right_shift, size)
 
#define ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL(a, size)   asymm_exp_on_interval_between_negative_one_quarter_and_0_excl##size(a)
 
#define ASYMM_SELECT_USING_MASK(if_mask, then_val, else_val, size)   asymm_select_using_mask##size(if_mask, then_val, else_val)
 
#define ASYMM_MASK_IF_ZERO(a, size)   asymm_mask_if_zero##size(a)
 
#define ASYMM_MASK_IF_NON_ZERO(a, size)   asymm_mask_if_non_zero##size(a)
 
#define EXP_BARREL_SHIFTER(result, exponent, fp_multiplier, k_integer_bits, k_fractional_bits, remainder, size)   exp_barrel_shifter##size(result, exponent, fp_multiplier, k_integer_bits, k_fractional_bits, remainder)
 
#define ASYMM_EXP_ON_NEGATIVE_VALUES_STR(a, k_integer_bits, size)   asymm_exp_on_negative_values##size(a, k_integer_bits)
 
#define ASYMM_EXP_ON_NEGATIVE_VALUES(a, k_integer_bits, size)   ASYMM_EXP_ON_NEGATIVE_VALUES_STR(a, k_integer_bits, size)
 
#define ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_STR(a, size)   asymm_one_over_one_plus_x_for_x_in_0_1##size(a)
 
#define ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1(a, size)   ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_STR(a, size)
 
#define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(x, exponent, size)   asymm_saturating_rounding_mult_by_pow2##size(x, exponent)
 
#define ASYMM_ROUNDING_HALF_SUM(a, b, size)   asymm_rounding_half_sum##size(a, b)
 
#define ASYMM_RESCALE_STR(value, src_integer_bits, dst_integer_bits, size)   asymm_rescale##size(value, src_integer_bits, dst_integer_bits)
 
#define ASYMM_RESCALE(value, src_integer_bits, dst_integer_bits, size)   ASYMM_RESCALE_STR(value, src_integer_bits, dst_integer_bits, size)
 
#define MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL(size)
 
#define MULTIPLY_BY_QUANTIZED_MULTIPLIER(input, qmul, shift, size)   multiply_by_quantized_multiplier##size(input, qmul, shift)
 

Functions

uchar quantize_qasymm8 (float input, float offset, float scale)
 Quantize a floating-point scalar value to 8-bit asymmetric. More...
 
float dequantize_qasymm8 (uchar input, float offset, float scale)
 Dequantize a scalar value from 8-bit asymmetric to floating-point. More...
 
float dequantize_qasymm8_signed (char input, float offset, float scale)
 Dequantize a scalar value from signed 8-bit asymmetric to floating-point. More...
 
uchar quantize_uchar1 (float input, float offset, float scale)
 
char quantize_char1 (float input, float offset, float scale)
 
uint quantize_uint1 (float input, float offset, float scale)
 
int quantize_int1 (float input, float offset, float scale)
 
uchar4 quantize_uchar4 (float4 input, float offset, float scale)
 
ushort4 quantize_ushort4 (float4 input, float offset, float scale)
 
short4 quantize_short4 (float4 input, float offset, float scale)
 
uchar16 quantize_uchar16 (float16 input, float offset, float scale)
 
char16 quantize_char16 (float16 input, float offset, float scale)
 
ushort16 quantize_ushort16 (float16 input, float offset, float scale)
 
short16 quantize_short16 (float16 input, float offset, float scale)
 
uint16 quantize_uint16 (float16 input, float offset, float scale)
 
int16 quantize_int16 (float16 input, float offset, float scale)
 
float dequantize_uchar1 (uchar input, float offset, float scale)
 
float dequantize_char1 (char input, float offset, float scale)
 
float dequantize_uint1 (uint input, float offset, float scale)
 
float dequantize_int1 (int input, float offset, float scale)
 
float4 dequantize_uchar4 (uchar4 input, float offset, float scale)
 
float4 dequantize_ushort4 (ushort4 input, float offset, float scale)
 
float4 dequantize_short4 (short4 input, float offset, float scale)
 
float16 dequantize_uchar16 (uchar16 input, float offset, float scale)
 
float16 dequantize_char16 (char16 input, float offset, float scale)
 
float16 dequantize_ushort16 (ushort16 input, float offset, float scale)
 
float16 dequantize_short16 (short16 input, float offset, float scale)
 
float16 dequantize_uint16 (uint16 input, float offset, float scale)
 
float16 dequantize_int16 (int16 input, float offset, float scale)
 
int asymm_rounding_divide_by_POW2_1 (int x, int exponent)
 
int2 asymm_rounding_divide_by_POW2_2 (int2 x, int2 exponent)
 
int3 asymm_rounding_divide_by_POW2_3 (int3 x, int3 exponent)
 
int4 asymm_rounding_divide_by_POW2_4 (int4 x, int4 exponent)
 
int8 asymm_rounding_divide_by_POW2_8 (int8 x, int8 exponent)
 
int16 asymm_rounding_divide_by_POW2_16 (int16 x, int16 exponent)
 
int asymm_mult1 (int a, int b)
 
int2 asymm_mult2 (int2 a, int2 b)
 
int3 asymm_mult3 (int3 a, int3 b)
 
int4 asymm_mult4 (int4 a, int4 b)
 
int8 asymm_mult8 (int8 a, int8 b)
 
int16 asymm_mult16 (int16 a, int16 b)
 
int asymm_exp_on_interval_between_negative_one_quarter_and_0_excl1 (int a)
 
int2 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl2 (int2 a)
 
int3 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl3 (int3 a)
 
int4 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl4 (int4 a)
 
int8 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl8 (int8 a)
 
int16 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl16 (int16 a)
 
int asymm_select_using_mask1 (int if_mask, int then_val, int else_val)
 
int2 asymm_select_using_mask2 (int2 if_mask, int2 then_val, int2 else_val)
 
int3 asymm_select_using_mask3 (int3 if_mask, int3 then_val, int3 else_val)
 
int4 asymm_select_using_mask4 (int4 if_mask, int4 then_val, int4 else_val)
 
int8 asymm_select_using_mask8 (int8 if_mask, int8 then_val, int8 else_val)
 
int16 asymm_select_using_mask16 (int16 if_mask, int16 then_val, int16 else_val)
 
int asymm_mask_if_zero1 (int a)
 
int2 asymm_mask_if_zero2 (int2 a)
 
int3 asymm_mask_if_zero3 (int3 a)
 
int4 asymm_mask_if_zero4 (int4 a)
 
int8 asymm_mask_if_zero8 (int8 a)
 
int16 asymm_mask_if_zero16 (int16 a)
 
int asymm_mask_if_non_zero1 (int a)
 
int2 asymm_mask_if_non_zero2 (int2 a)
 
int3 asymm_mask_if_non_zero3 (int3 a)
 
int4 asymm_mask_if_non_zero4 (int4 a)
 
int8 asymm_mask_if_non_zero8 (int8 a)
 
int16 asymm_mask_if_non_zero16 (int16 a)
 
int exp_barrel_shifter1 (int result, int exponent, int fp_multiplier, int k_integer_bits, int k_fractional_bits, int remainder)
 
int2 exp_barrel_shifter2 (int2 result, int exponent, int fp_multiplier, int k_integer_bits, int k_fractional_bits, int2 remainder)
 
int3 exp_barrel_shifter3 (int3 result, int exponent, int fp_multiplier, int k_integer_bits, int k_fractional_bits, int3 remainder)
 
int4 exp_barrel_shifter4 (int4 result, int exponent, int fp_multiplier, int k_integer_bits, int k_fractional_bits, int4 remainder)
 
int8 exp_barrel_shifter8 (int8 result, int exponent, int fp_multiplier, int k_integer_bits, int k_fractional_bits, int8 remainder)
 
int16 exp_barrel_shifter16 (int16 result, int exponent, int fp_multiplier, int k_integer_bits, int k_fractional_bits, int16 remainder)
 
int asymm_exp_on_negative_values1 (int a, int k_integer_bits)
 
int2 asymm_exp_on_negative_values2 (int2 a, int k_integer_bits)
 
int3 asymm_exp_on_negative_values3 (int3 a, int k_integer_bits)
 
int4 asymm_exp_on_negative_values4 (int4 a, int k_integer_bits)
 
int8 asymm_exp_on_negative_values8 (int8 a, int k_integer_bits)
 
int16 asymm_exp_on_negative_values16 (int16 a, int k_integer_bits)
 
int asymm_saturating_rounding_mult_by_pow21 (int x, int exponent)
 
int2 asymm_saturating_rounding_mult_by_pow22 (int2 x, int exponent)
 
int3 asymm_saturating_rounding_mult_by_pow23 (int3 x, int exponent)
 
int4 asymm_saturating_rounding_mult_by_pow24 (int4 x, int exponent)
 
int8 asymm_saturating_rounding_mult_by_pow28 (int8 x, int exponent)
 
int16 asymm_saturating_rounding_mult_by_pow216 (int16 x, int exponent)
 
int asymm_rounding_half_sum1 (int a, int b)
 
int2 asymm_rounding_half_sum2 (int2 a, int2 b)
 
int3 asymm_rounding_half_sum3 (int3 a, int3 b)
 
int4 asymm_rounding_half_sum4 (int4 a, int4 b)
 
int8 asymm_rounding_half_sum8 (int8 a, int8 b)
 
int16 asymm_rounding_half_sum16 (int16 a, int16 b)
 
int asymm_one_over_one_plus_x_for_x_in_0_11 (int a)
 
int2 asymm_one_over_one_plus_x_for_x_in_0_12 (int2 a)
 
int3 asymm_one_over_one_plus_x_for_x_in_0_13 (int3 a)
 
int4 asymm_one_over_one_plus_x_for_x_in_0_14 (int4 a)
 
int8 asymm_one_over_one_plus_x_for_x_in_0_18 (int8 a)
 
int16 asymm_one_over_one_plus_x_for_x_in_0_116 (int16 a)
 
int asymm_rescale1 (int value, int src_integer_bits, int dst_integer_bits)
 
int2 asymm_rescale2 (int2 value, int src_integer_bits, int dst_integer_bits)
 
int3 asymm_rescale3 (int3 value, int src_integer_bits, int dst_integer_bits)
 
int4 asymm_rescale4 (int4 value, int src_integer_bits, int dst_integer_bits)
 
int8 asymm_rescale8 (int8 value, int src_integer_bits, int dst_integer_bits)
 
int16 asymm_rescale16 (int16 value, int src_integer_bits, int dst_integer_bits)
 
int multiply_by_quantized_multiplier1 (int input, int qmul, int shift)
 
int2 multiply_by_quantized_multiplier2 (int2 input, int qmul, int shift)
 
int3 multiply_by_quantized_multiplier3 (int3 input, int qmul, int shift)
 
int4 multiply_by_quantized_multiplier4 (int4 input, int qmul, int shift)
 
int8 multiply_by_quantized_multiplier8 (int8 input, int qmul, int shift)
 
int16 multiply_by_quantized_multiplier16 (int16 input, int qmul, int shift)
 

Macro Definition Documentation

◆ ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL

#define ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL (   a,
  size 
)    asymm_exp_on_interval_between_negative_one_quarter_and_0_excl##size(a)

Definition at line 401 of file helpers_asymm.h.

◆ ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL

#define ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_exp_on_interval_between_negative_one_quarter_and_0_excl##size(VEC_DATA_TYPE(int, size) a) \
{ \
const VEC_DATA_TYPE(int, size) constant_term = 1895147668; \
const VEC_DATA_TYPE(int, size) constant_1_over_3 = 715827883; \
const int k_fractional_bits = 31; \
VEC_DATA_TYPE(int, size) \
x = a + (1 << (k_fractional_bits - 3)); \
VEC_DATA_TYPE(int, size) \
x2 = ASYMM_MULT(x, x, size); \
VEC_DATA_TYPE(int, size) \
x3 = ASYMM_MULT(x2, x, size); \
VEC_DATA_TYPE(int, size) \
x4 = ASYMM_MULT(x2, x2, size); \
VEC_DATA_TYPE(int, size) \
x4_over_4 = ASYMM_ROUNDING_DIVIDE_BY_POW2(x4, 2, size); \
VEC_DATA_TYPE(int, size) \
x4_over_24_plus_x3_over_6_plus_x2 = ASYMM_MULT((x4_over_4 + x3), constant_1_over_3, size) + x2; \
VEC_DATA_TYPE(int, size) \
x4_over_24_plus_x3_over_6_plus_x2_over_2 = ASYMM_ROUNDING_DIVIDE_BY_POW2(x4_over_24_plus_x3_over_6_plus_x2, 1, size); \
return constant_term + ASYMM_MULT(constant_term, x + x4_over_24_plus_x3_over_6_plus_x2_over_2, size); \
}
#define ASYMM_MULT(a, b, size)
#define ASYMM_ROUNDING_DIVIDE_BY_POW2(x, exponent, size)
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Calculates \( exp(x) \) for x in [-1/4, 0).

Parameters
[in]sizeSize of vector.
Returns
Result in fixed-point format Q0.

Definition at line 170 of file helpers_asymm.h.

◆ ASYMM_EXP_ON_NEGATIVE_VALUES

#define ASYMM_EXP_ON_NEGATIVE_VALUES (   a,
  k_integer_bits,
  size 
)    ASYMM_EXP_ON_NEGATIVE_VALUES_STR(a, k_integer_bits, size)

Definition at line 407 of file helpers_asymm.h.

◆ ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL

#define ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL (   size)

Calculates \( exp(x) \) for x < 0.

Parameters
[in]sizeSize of vector.
Returns
Result in fixed-point format Q0.

Definition at line 257 of file helpers_asymm.h.

◆ ASYMM_EXP_ON_NEGATIVE_VALUES_STR

#define ASYMM_EXP_ON_NEGATIVE_VALUES_STR (   a,
  k_integer_bits,
  size 
)    asymm_exp_on_negative_values##size(a, k_integer_bits)

Definition at line 406 of file helpers_asymm.h.

◆ ASYMM_MASK_IF_NON_ZERO

#define ASYMM_MASK_IF_NON_ZERO (   a,
  size 
)    asymm_mask_if_non_zero##size(a)

Definition at line 404 of file helpers_asymm.h.

◆ ASYMM_MASK_IF_NON_ZERO_IMPL

#define ASYMM_MASK_IF_NON_ZERO_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_mask_if_non_zero##size(VEC_DATA_TYPE(int, size) a) \
{ \
const VEC_DATA_TYPE(int, size) all_zeros = 0; \
const VEC_DATA_TYPE(int, size) all_ones = ~0; \
return select(all_zeros, all_ones, (SELECT_VEC_DATA_TYPE(int, size))(a != 0)); \
}
SimpleTensor< T > select(const SimpleTensor< uint8_t > &c, const SimpleTensor< T > &x, const SimpleTensor< T > &y)
Definition: Select.cpp:38
#define SELECT_VEC_DATA_TYPE(type, size)
Definition: helpers.h:537
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

For each element of input vector, the corresponding bits of the result item are set if the input item is non-zero.

Parameters
[in]sizeSize of vector.
Returns
Output vector with bits set when corresponding bit in a is non zero.

Definition at line 229 of file helpers_asymm.h.

◆ ASYMM_MASK_IF_ZERO

#define ASYMM_MASK_IF_ZERO (   a,
  size 
)    asymm_mask_if_zero##size(a)

Definition at line 403 of file helpers_asymm.h.

◆ ASYMM_MASK_IF_ZERO_IMPL

#define ASYMM_MASK_IF_ZERO_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_mask_if_zero##size(VEC_DATA_TYPE(int, size) a) \
{ \
const VEC_DATA_TYPE(int, size) all_zeros = 0; \
const VEC_DATA_TYPE(int, size) all_ones = ~0; \
return select(all_zeros, all_ones, (SELECT_VEC_DATA_TYPE(int, size))(a == 0)); \
}
SimpleTensor< T > select(const SimpleTensor< uint8_t > &c, const SimpleTensor< T > &x, const SimpleTensor< T > &y)
Definition: Select.cpp:38
#define SELECT_VEC_DATA_TYPE(type, size)
Definition: helpers.h:537
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

For each element of input vector, the corresponding bits of the result item are set if the input item is zero.

Parameters
[in]sizeSize of vector.
Returns
Output vector with bits set when corresponding bit in a is zero.

Definition at line 214 of file helpers_asymm.h.

◆ ASYMM_MULT

#define ASYMM_MULT (   a,
  b,
  size 
)    ASYMM_MULT_STR(a, b, size)

Definition at line 396 of file helpers_asymm.h.

Referenced by get_invsqrt_quantized_multiplier_exp().

◆ ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE

#define ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE (   x,
  quantized_multiplier,
  left_shift,
  size 
)    ASYMM_MULT(x *((VEC_DATA_TYPE(int, size))(1) << (-left_shift)), quantized_multiplier, size)

Definition at line 397 of file helpers_asymm.h.

◆ ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE

#define ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE (   x,
  quantized_multiplier,
  right_shift,
  size 
)    ASYMM_ROUNDING_DIVIDE_BY_POW2(ASYMM_MULT(x, quantized_multiplier, size), right_shift, size)

Definition at line 399 of file helpers_asymm.h.

◆ ASYMM_MULT_IMPL

#define ASYMM_MULT_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_mult##size(VEC_DATA_TYPE(int, size) a, VEC_DATA_TYPE(int, size) b) \
{ \
VEC_DATA_TYPE(int, size) \
overflow = a == b && a == INT_MIN; \
VEC_DATA_TYPE(long, size) \
a_64 = convert_long##size(a); \
VEC_DATA_TYPE(long, size) \
b_64 = convert_long##size(b); \
VEC_DATA_TYPE(long, size) \
ab_64 = a_64 * b_64; \
/* Revert COMPMID-907 */ \
VEC_DATA_TYPE(long, size) \
mask1 = 1 << 30; \
VEC_DATA_TYPE(long, size) \
mask2 = 1 - (1 << 30); \
VEC_DATA_TYPE(long, size) \
is_positive_or_zero = ab_64 >= 0; \
VEC_DATA_TYPE(long, size) \
nudge = select(mask2, mask1, (SELECT_VEC_DATA_TYPE(long, size))(is_positive_or_zero)); \
VEC_DATA_TYPE(long, size) \
mask = 1ll << 31; \
VEC_DATA_TYPE(int, size) \
ab_x2_high32 = convert_int##size((ab_64 + nudge) / mask); \
return select(ab_x2_high32, INT_MAX, (SELECT_VEC_DATA_TYPE(int, size))(overflow)); \
}
SimpleTensor< float > b
Definition: DFT.cpp:157
SimpleTensor< T > select(const SimpleTensor< uint8_t > &c, const SimpleTensor< T > &x, const SimpleTensor< T > &y)
Definition: Select.cpp:38
#define SELECT_VEC_DATA_TYPE(type, size)
Definition: helpers.h:537
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Product of two numbers, interpreting them as fixed-point values in the interval [-1, 1), rounding to the nearest value, and saturating -1 * -1 to the maximum value.

Parameters
[in]sizeSize of vector.
Returns
Product of two fixed-point numbers.

Definition at line 137 of file helpers_asymm.h.

◆ ASYMM_MULT_STR

#define ASYMM_MULT_STR (   a,
  b,
  size 
)    asymm_mult##size(a, b)

Definition at line 395 of file helpers_asymm.h.

◆ ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1

#define ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1 (   a,
  size 
)    ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_STR(a, size)

Definition at line 409 of file helpers_asymm.h.

◆ ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL

#define ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_one_over_one_plus_x_for_x_in_0_1##size(VEC_DATA_TYPE(int, size) a) \
{ \
const VEC_DATA_TYPE(int, size) Q0_one = INT_MAX; \
const VEC_DATA_TYPE(int, size) Q2_one = 1 << (31 - 2); \
VEC_DATA_TYPE(int, size) \
half_denominator = ASYMM_ROUNDING_HALF_SUM(a, Q0_one, size); \
const VEC_DATA_TYPE(int, size) Q2_48_over_17 = 1515870810; \
const VEC_DATA_TYPE(int, size) Q2_neg_32_over_17 = -1010580540; \
VEC_DATA_TYPE(int, size) \
x = Q2_48_over_17 + ASYMM_MULT(half_denominator, Q2_neg_32_over_17, size); \
for(int i = 0; i < 3; i++) \
{ \
VEC_DATA_TYPE(int, size) \
half_denominator_times_x = ASYMM_MULT(half_denominator, x, size); \
VEC_DATA_TYPE(int, size) \
one_minus_half_denominator_times_x = Q2_one - half_denominator_times_x; \
VEC_DATA_TYPE(int, size) \
tmp = ASYMM_MULT(x, one_minus_half_denominator_times_x, size); \
x = x + ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(tmp, 2, size); \
} \
}
#define ASYMM_MULT(a, b, size)
#define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(x, exponent, size)
#define ASYMM_ROUNDING_HALF_SUM(a, b, size)
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Calculates \( 1 / (1 + x) \) for x in (0, 1).

Parameters
[in]sizeSize of vector.
Returns
Result in fixed-point format Q0.

Definition at line 351 of file helpers_asymm.h.

◆ ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_STR

#define ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_STR (   a,
  size 
)    asymm_one_over_one_plus_x_for_x_in_0_1##size(a)

Definition at line 408 of file helpers_asymm.h.

◆ ASYMM_RESCALE

#define ASYMM_RESCALE (   value,
  src_integer_bits,
  dst_integer_bits,
  size 
)    ASYMM_RESCALE_STR(value, src_integer_bits, dst_integer_bits, size)

Definition at line 413 of file helpers_asymm.h.

Referenced by get_invsqrt_quantized_multiplier_exp().

◆ ASYMM_RESCALE_IMPL

#define ASYMM_RESCALE_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_rescale##size(VEC_DATA_TYPE(int, size) value, int src_integer_bits, int dst_integer_bits) \
{ \
int exponent = src_integer_bits - dst_integer_bits; \
return ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(value, exponent, size); \
}
#define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(x, exponent, size)
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Considering the integer value as fixed-point, change the number of integer bits and update value accordingly.

Parameters
[in]sizeSize of vector.
Returns
Rescaled value.

Definition at line 381 of file helpers_asymm.h.

◆ ASYMM_RESCALE_STR

#define ASYMM_RESCALE_STR (   value,
  src_integer_bits,
  dst_integer_bits,
  size 
)    asymm_rescale##size(value, src_integer_bits, dst_integer_bits)

Definition at line 412 of file helpers_asymm.h.

◆ ASYMM_ROUNDING_DIVIDE_BY_POW2

#define ASYMM_ROUNDING_DIVIDE_BY_POW2 (   x,
  exponent,
  size 
)    ASYMM_ROUNDING_DIVIDE_BY_POW2_STR(x, exponent, size)

Definition at line 394 of file helpers_asymm.h.

Referenced by get_invsqrt_quantized_multiplier_exp().

◆ ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL

#define ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_rounding_divide_by_POW2_##size(VEC_DATA_TYPE(int, size) x, VEC_DATA_TYPE(int, size) exponent) \
{ \
const VEC_DATA_TYPE(int, size) \
zero = (VEC_DATA_TYPE(int, size))0; \
const VEC_DATA_TYPE(int, size) \
one = (VEC_DATA_TYPE(int, size))1; \
VEC_DATA_TYPE(int, size) \
mask = (one << exponent) - one; \
VEC_DATA_TYPE(int, size) \
threshold = (mask >> 1) + select(zero, one, (SELECT_VEC_DATA_TYPE(int, size))(x < 0)); \
return (x >> exponent) + select(zero, one, (SELECT_VEC_DATA_TYPE(int, size))((x & mask) > threshold)); \
}
SimpleTensor< T > select(const SimpleTensor< uint8_t > &c, const SimpleTensor< T > &x, const SimpleTensor< T > &y)
Definition: Select.cpp:38
#define SELECT_VEC_DATA_TYPE(type, size)
Definition: helpers.h:537
SimpleTensor< T > threshold(const SimpleTensor< T > &src, T threshold, T false_value, T true_value, ThresholdType type, T upper)
Definition: Threshold.cpp:35
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Correctly-rounded-to-nearest division by a power-of-two.

Parameters
[in]sizeSize of vector.
Returns
Correctly-rounded-to-nearest division by a power-of-two.

Definition at line 116 of file helpers_asymm.h.

◆ ASYMM_ROUNDING_DIVIDE_BY_POW2_STR

#define ASYMM_ROUNDING_DIVIDE_BY_POW2_STR (   x,
  exponent,
  size 
)    asymm_rounding_divide_by_POW2_##size(x, exponent)

Definition at line 393 of file helpers_asymm.h.

◆ ASYMM_ROUNDING_HALF_SUM

#define ASYMM_ROUNDING_HALF_SUM (   a,
  b,
  size 
)    asymm_rounding_half_sum##size(a, b)

Definition at line 411 of file helpers_asymm.h.

◆ ASYMM_ROUNDING_HALF_SUM_IMPL

#define ASYMM_ROUNDING_HALF_SUM_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_rounding_half_sum##size(VEC_DATA_TYPE(int, size) a, VEC_DATA_TYPE(int, size) b) \
{ \
VEC_DATA_TYPE(long, size) \
a64 = convert_long##size(a); \
VEC_DATA_TYPE(long, size) \
b64 = convert_long##size(b); \
VEC_DATA_TYPE(long, size) \
sum = a64 + b64; \
const VEC_DATA_TYPE(long, size) one = 1; \
const VEC_DATA_TYPE(long, size) minus_one = -1; \
VEC_DATA_TYPE(long, size) \
sign = select(minus_one, one, (SELECT_VEC_DATA_TYPE(long, size))(sum >= 0)); \
return convert_int##size((sum + sign) / 2); \
}
SimpleTensor< float > b
Definition: DFT.cpp:157
DATA_TYPE sum(__global const DATA_TYPE *input)
Calculate sum of a vector.
SimpleTensor< T > select(const SimpleTensor< uint8_t > &c, const SimpleTensor< T > &x, const SimpleTensor< T > &y)
Definition: Select.cpp:38
#define SELECT_VEC_DATA_TYPE(type, size)
Definition: helpers.h:537
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Calculates (a+b)/2, rounded to the nearest integer.

Equivalent to VRHADD in the Arm Neon instruction set.

Parameters
[in]sizeSize of vector.
Returns
(a+b)/2, rounded to the nearest integer.

Definition at line 329 of file helpers_asymm.h.

◆ ASYMM_SATURATING_ROUNDING_MULT_BY_POW2

#define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2 (   x,
  exponent,
  size 
)    asymm_saturating_rounding_mult_by_pow2##size(x, exponent)

Definition at line 410 of file helpers_asymm.h.

◆ ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL

#define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_saturating_rounding_mult_by_pow2##size(VEC_DATA_TYPE(int, size) x, int exponent) \
{ \
if(exponent < 0) \
{ \
return ASYMM_ROUNDING_DIVIDE_BY_POW2(x, -exponent, size); \
} \
\
const VEC_DATA_TYPE(int, size) min = INT_MIN; \
const VEC_DATA_TYPE(int, size) max = INT_MAX; \
int threshold = ((1 << (31 - exponent)) - 1); \
VEC_DATA_TYPE(int, size) \
positive_mask = ASYMM_MASK_IF_NON_ZERO(x > threshold, size); \
VEC_DATA_TYPE(int, size) \
negative_mask = ASYMM_MASK_IF_NON_ZERO(x < -threshold, size); \
VEC_DATA_TYPE(int, size) \
result = x << exponent; \
result = ASYMM_SELECT_USING_MASK(positive_mask, max, result, size); \
result = ASYMM_SELECT_USING_MASK(negative_mask, min, result, size); \
return result; \
}
#define ASYMM_ROUNDING_DIVIDE_BY_POW2(x, exponent, size)
#define ASYMM_MASK_IF_NON_ZERO(a, size)
#define ASYMM_SELECT_USING_MASK(if_mask, then_val, else_val, size)
SimpleTensor< T > threshold(const SimpleTensor< T > &src, T threshold, T false_value, T true_value, ThresholdType type, T upper)
Definition: Threshold.cpp:35
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Calculates the product of a integer value by a power of two, with either a positive exponent (equivalent to an arithmetic left shift, saturating) or a negative exponent (equivalent to an arithmetic right shift, rounding to nearest).

Parameters
[in]sizeSize of vector.
Returns
Arithmetic left or right shift.

Definition at line 300 of file helpers_asymm.h.

◆ ASYMM_SELECT_USING_MASK

#define ASYMM_SELECT_USING_MASK (   if_mask,
  then_val,
  else_val,
  size 
)    asymm_select_using_mask##size(if_mask, then_val, else_val)

Definition at line 402 of file helpers_asymm.h.

◆ ASYMM_SELECT_USING_MASK_IMPL

#define ASYMM_SELECT_USING_MASK_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) asymm_select_using_mask##size(VEC_DATA_TYPE(int, size) if_mask, VEC_DATA_TYPE(int, size) then_val, VEC_DATA_TYPE(int, size) else_val) \
{ \
return (if_mask & then_val) ^ (~if_mask & else_val); \
}
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Each bit of the result is set to the corresponding bit of either then_val or else_val depending on whether the corresponding bit of if_mask is set.

Equivalent to the VBSL instruction in Arm Neon.

Parameters
[in]sizeSize of vector.
Returns
Result contaning bits from then_val or from else_val depending on corresponding bit in if_mask is set or not.

Definition at line 201 of file helpers_asymm.h.

◆ CONVERT_DOWN_RTE

#define CONVERT_DOWN_RTE (   x,
  type 
)    CONVERT_DOWN_RTE_STR(x, type)

Definition at line 37 of file helpers_asymm.h.

Referenced by quantize_qasymm8().

◆ CONVERT_DOWN_RTE_STR

#define CONVERT_DOWN_RTE_STR (   x,
  type 
)    (convert_##type##_rte((x)))

Convert the given vector with round to nearest even rounding mode.

Parameters
[in]xThe target to be converted
[in]typeThe target type
Returns
The converted vector

Definition at line 36 of file helpers_asymm.h.

◆ DEQUANTIZE

#define DEQUANTIZE (   input,
  offset,
  scale,
  type,
  size 
)    DEQUANTIZE_STR(input, offset, scale, type, size)

Definition at line 391 of file helpers_asymm.h.

Referenced by product().

◆ DEQUANTIZE_IMPL

#define DEQUANTIZE_IMPL (   type,
  size 
)
Value:
inline VEC_DATA_TYPE(float, size) dequantize_##type##size(VEC_DATA_TYPE(type, size) input, float offset, float scale) \
{ \
return (CONVERT(input, VEC_DATA_TYPE(float, size)) - offset) * scale; \
}
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:846
#define CONVERT(x, type)
Definition: helpers.h:517
decltype(strategy::transforms) typedef type
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Dequantize a vector of values to floating-point.

Parameters
[in]typeInput data type.
[in]sizeSize of vector.
Returns
dequantized values in floating point

Definition at line 104 of file helpers_asymm.h.

◆ DEQUANTIZE_STR

#define DEQUANTIZE_STR (   input,
  offset,
  scale,
  type,
  size 
)    dequantize_##type##size(input, offset, scale)

Definition at line 390 of file helpers_asymm.h.

◆ EXP_BARREL_SHIFTER

#define EXP_BARREL_SHIFTER (   result,
  exponent,
  fp_multiplier,
  k_integer_bits,
  k_fractional_bits,
  remainder,
  size 
)    exp_barrel_shifter##size(result, exponent, fp_multiplier, k_integer_bits, k_fractional_bits, remainder)

Definition at line 405 of file helpers_asymm.h.

◆ EXP_BARREL_SHIFTER_IMPL

#define EXP_BARREL_SHIFTER_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) exp_barrel_shifter##size(VEC_DATA_TYPE(int, size) result, int exponent, int fp_multiplier, int k_integer_bits, int k_fractional_bits, VEC_DATA_TYPE(int, size) remainder) \
{ \
if(k_integer_bits > exponent) \
{ \
const int k_shift_amount = k_integer_bits > exponent ? k_fractional_bits + exponent : 0; \
ASYMM_MASK_IF_NON_ZERO(remainder & (1 << k_shift_amount), size), \
ASYMM_MULT(result, fp_multiplier, size), result, size); \
} \
\
return result; \
}
#define ASYMM_MULT(a, b, size)
#define ASYMM_MASK_IF_NON_ZERO(a, size)
#define ASYMM_SELECT_USING_MASK(if_mask, then_val, else_val, size)
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Definition at line 237 of file helpers_asymm.h.

◆ MULTIPLY_BY_QUANTIZED_MULTIPLIER

#define MULTIPLY_BY_QUANTIZED_MULTIPLIER (   input,
  qmul,
  shift,
  size 
)    multiply_by_quantized_multiplier##size(input, qmul, shift)

Definition at line 422 of file helpers_asymm.h.

Referenced by get_invsqrt_quantized_multiplier_exp().

◆ MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL

#define MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL (   size)
Value:
inline VEC_DATA_TYPE(int, size) multiply_by_quantized_multiplier##size(VEC_DATA_TYPE(int, size) input, int qmul, int shift) \
{ \
const int left_shift = shift > 0 ? shift : 0; \
const int right_shift = shift > 0 ? 0 : -shift; \
return ASYMM_ROUNDING_DIVIDE_BY_POW2(ASYMM_MULT(input * (1 << left_shift), qmul, size), right_shift, size); \
}
#define ASYMM_MULT(a, b, size)
#define ASYMM_ROUNDING_DIVIDE_BY_POW2(x, exponent, size)
#define multiply_by_quantized_multiplier(input, qmul, shift)
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Definition at line 415 of file helpers_asymm.h.

◆ QUANTIZE

#define QUANTIZE (   input,
  offset,
  scale,
  type,
  size 
)    QUANTIZE_STR(input, offset, scale, type, size)

Definition at line 389 of file helpers_asymm.h.

Referenced by direct_convolution_nhwc(), and product().

◆ QUANTIZE_IMPL

#define QUANTIZE_IMPL (   type,
  size 
)
Value:
inline VEC_DATA_TYPE(type, size) quantize_##type##size(VEC_DATA_TYPE(float, size) input, float offset, float scale) \
{ \
VEC_DATA_TYPE(float, size) \
out_f32 = input / (VEC_DATA_TYPE(float, size))(scale) + (VEC_DATA_TYPE(float, size))(offset); \
VEC_DATA_TYPE(type, size) \
res = CONVERT_SAT(CONVERT_DOWN_RTE(out_f32, VEC_DATA_TYPE(int, size)), VEC_DATA_TYPE(type, size)); \
return res; \
}
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:846
#define CONVERT_SAT(a, b)
decltype(strategy::transforms) typedef type
#define CONVERT_DOWN_RTE(x, type)
Definition: helpers_asymm.h:37
#define VEC_DATA_TYPE(type, size)
Definition: helpers.h:514

Quantize a vector of values from floating-point.

Parameters
[in]typeOutput data type.
[in]sizeSize of vector.
Returns
quantized values

Definition at line 87 of file helpers_asymm.h.

◆ QUANTIZE_STR

#define QUANTIZE_STR (   input,
  offset,
  scale,
  type,
  size 
)    quantize_##type##size(input, offset, scale)

Definition at line 388 of file helpers_asymm.h.

Function Documentation

◆ asymm_exp_on_interval_between_negative_one_quarter_and_0_excl1()

int asymm_exp_on_interval_between_negative_one_quarter_and_0_excl1 ( int  a)
inline

Definition at line 466 of file helpers_asymm.h.

◆ asymm_exp_on_interval_between_negative_one_quarter_and_0_excl16()

int16 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl16 ( int16  a)
inline

Definition at line 471 of file helpers_asymm.h.

◆ asymm_exp_on_interval_between_negative_one_quarter_and_0_excl2()

int2 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl2 ( int2  a)
inline

Definition at line 467 of file helpers_asymm.h.

◆ asymm_exp_on_interval_between_negative_one_quarter_and_0_excl3()

int3 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl3 ( int3  a)
inline

Definition at line 468 of file helpers_asymm.h.

◆ asymm_exp_on_interval_between_negative_one_quarter_and_0_excl4()

int4 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl4 ( int4  a)
inline

Definition at line 469 of file helpers_asymm.h.

◆ asymm_exp_on_interval_between_negative_one_quarter_and_0_excl8()

int8 asymm_exp_on_interval_between_negative_one_quarter_and_0_excl8 ( int8  a)
inline

Definition at line 470 of file helpers_asymm.h.

◆ asymm_exp_on_negative_values1()

int asymm_exp_on_negative_values1 ( int  a,
int  k_integer_bits 
)
inline

Definition at line 501 of file helpers_asymm.h.

◆ asymm_exp_on_negative_values16()

int16 asymm_exp_on_negative_values16 ( int16  a,
int  k_integer_bits 
)
inline

Definition at line 506 of file helpers_asymm.h.

◆ asymm_exp_on_negative_values2()

int2 asymm_exp_on_negative_values2 ( int2  a,
int  k_integer_bits 
)
inline

Definition at line 502 of file helpers_asymm.h.

◆ asymm_exp_on_negative_values3()

int3 asymm_exp_on_negative_values3 ( int3  a,
int  k_integer_bits 
)
inline

Definition at line 503 of file helpers_asymm.h.

◆ asymm_exp_on_negative_values4()

int4 asymm_exp_on_negative_values4 ( int4  a,
int  k_integer_bits 
)
inline

Definition at line 504 of file helpers_asymm.h.

◆ asymm_exp_on_negative_values8()

int8 asymm_exp_on_negative_values8 ( int8  a,
int  k_integer_bits 
)
inline

Definition at line 505 of file helpers_asymm.h.

◆ asymm_mask_if_non_zero1()

int asymm_mask_if_non_zero1 ( int  a)
inline

Definition at line 487 of file helpers_asymm.h.

◆ asymm_mask_if_non_zero16()

int16 asymm_mask_if_non_zero16 ( int16  a)
inline

Definition at line 492 of file helpers_asymm.h.

◆ asymm_mask_if_non_zero2()

int2 asymm_mask_if_non_zero2 ( int2  a)
inline

Definition at line 488 of file helpers_asymm.h.

◆ asymm_mask_if_non_zero3()

int3 asymm_mask_if_non_zero3 ( int3  a)
inline

Definition at line 489 of file helpers_asymm.h.

◆ asymm_mask_if_non_zero4()

int4 asymm_mask_if_non_zero4 ( int4  a)
inline

Definition at line 490 of file helpers_asymm.h.

◆ asymm_mask_if_non_zero8()

int8 asymm_mask_if_non_zero8 ( int8  a)
inline

Definition at line 491 of file helpers_asymm.h.

◆ asymm_mask_if_zero1()

int asymm_mask_if_zero1 ( int  a)
inline

Definition at line 480 of file helpers_asymm.h.

◆ asymm_mask_if_zero16()

int16 asymm_mask_if_zero16 ( int16  a)
inline

Definition at line 485 of file helpers_asymm.h.

◆ asymm_mask_if_zero2()

int2 asymm_mask_if_zero2 ( int2  a)
inline

Definition at line 481 of file helpers_asymm.h.

◆ asymm_mask_if_zero3()

int3 asymm_mask_if_zero3 ( int3  a)
inline

Definition at line 482 of file helpers_asymm.h.

◆ asymm_mask_if_zero4()

int4 asymm_mask_if_zero4 ( int4  a)
inline

Definition at line 483 of file helpers_asymm.h.

◆ asymm_mask_if_zero8()

int8 asymm_mask_if_zero8 ( int8  a)
inline

Definition at line 484 of file helpers_asymm.h.

◆ asymm_mult1()

int asymm_mult1 ( int  a,
int  b 
)
inline

Definition at line 459 of file helpers_asymm.h.

◆ asymm_mult16()

int16 asymm_mult16 ( int16  a,
int16  b 
)
inline

Definition at line 464 of file helpers_asymm.h.

◆ asymm_mult2()

int2 asymm_mult2 ( int2  a,
int2  b 
)
inline

Definition at line 460 of file helpers_asymm.h.

◆ asymm_mult3()

int3 asymm_mult3 ( int3  a,
int3  b 
)
inline

Definition at line 461 of file helpers_asymm.h.

◆ asymm_mult4()

int4 asymm_mult4 ( int4  a,
int4  b 
)
inline

Definition at line 462 of file helpers_asymm.h.

◆ asymm_mult8()

int8 asymm_mult8 ( int8  a,
int8  b 
)
inline

Definition at line 463 of file helpers_asymm.h.

◆ asymm_one_over_one_plus_x_for_x_in_0_11()

int asymm_one_over_one_plus_x_for_x_in_0_11 ( int  a)
inline

Definition at line 522 of file helpers_asymm.h.

◆ asymm_one_over_one_plus_x_for_x_in_0_116()

int16 asymm_one_over_one_plus_x_for_x_in_0_116 ( int16  a)
inline

Definition at line 527 of file helpers_asymm.h.

◆ asymm_one_over_one_plus_x_for_x_in_0_12()

int2 asymm_one_over_one_plus_x_for_x_in_0_12 ( int2  a)
inline

Definition at line 523 of file helpers_asymm.h.

◆ asymm_one_over_one_plus_x_for_x_in_0_13()

int3 asymm_one_over_one_plus_x_for_x_in_0_13 ( int3  a)
inline

Definition at line 524 of file helpers_asymm.h.

◆ asymm_one_over_one_plus_x_for_x_in_0_14()

int4 asymm_one_over_one_plus_x_for_x_in_0_14 ( int4  a)
inline

Definition at line 525 of file helpers_asymm.h.

◆ asymm_one_over_one_plus_x_for_x_in_0_18()

int8 asymm_one_over_one_plus_x_for_x_in_0_18 ( int8  a)
inline

Definition at line 526 of file helpers_asymm.h.

◆ asymm_rescale1()

int asymm_rescale1 ( int  value,
int  src_integer_bits,
int  dst_integer_bits 
)
inline

Definition at line 529 of file helpers_asymm.h.

◆ asymm_rescale16()

int16 asymm_rescale16 ( int16  value,
int  src_integer_bits,
int  dst_integer_bits 
)
inline

Definition at line 534 of file helpers_asymm.h.

◆ asymm_rescale2()

int2 asymm_rescale2 ( int2  value,
int  src_integer_bits,
int  dst_integer_bits 
)
inline

Definition at line 530 of file helpers_asymm.h.

◆ asymm_rescale3()

int3 asymm_rescale3 ( int3  value,
int  src_integer_bits,
int  dst_integer_bits 
)
inline

Definition at line 531 of file helpers_asymm.h.

◆ asymm_rescale4()

int4 asymm_rescale4 ( int4  value,
int  src_integer_bits,
int  dst_integer_bits 
)
inline

Definition at line 532 of file helpers_asymm.h.

◆ asymm_rescale8()

int8 asymm_rescale8 ( int8  value,
int  src_integer_bits,
int  dst_integer_bits 
)
inline

Definition at line 533 of file helpers_asymm.h.

◆ asymm_rounding_divide_by_POW2_1()

int asymm_rounding_divide_by_POW2_1 ( int  x,
int  exponent 
)
inline

Definition at line 452 of file helpers_asymm.h.

◆ asymm_rounding_divide_by_POW2_16()

int16 asymm_rounding_divide_by_POW2_16 ( int16  x,
int16  exponent 
)
inline

Definition at line 457 of file helpers_asymm.h.

◆ asymm_rounding_divide_by_POW2_2()

int2 asymm_rounding_divide_by_POW2_2 ( int2  x,
int2  exponent 
)
inline

Definition at line 453 of file helpers_asymm.h.

◆ asymm_rounding_divide_by_POW2_3()

int3 asymm_rounding_divide_by_POW2_3 ( int3  x,
int3  exponent 
)
inline

Definition at line 454 of file helpers_asymm.h.

◆ asymm_rounding_divide_by_POW2_4()

int4 asymm_rounding_divide_by_POW2_4 ( int4  x,
int4  exponent 
)
inline

Definition at line 455 of file helpers_asymm.h.

◆ asymm_rounding_divide_by_POW2_8()

int8 asymm_rounding_divide_by_POW2_8 ( int8  x,
int8  exponent 
)
inline

Definition at line 456 of file helpers_asymm.h.

◆ asymm_rounding_half_sum1()

int asymm_rounding_half_sum1 ( int  a,
int  b 
)
inline

Definition at line 515 of file helpers_asymm.h.

◆ asymm_rounding_half_sum16()

int16 asymm_rounding_half_sum16 ( int16  a,
int16  b 
)
inline

Definition at line 520 of file helpers_asymm.h.

◆ asymm_rounding_half_sum2()

int2 asymm_rounding_half_sum2 ( int2  a,
int2  b 
)
inline

Definition at line 516 of file helpers_asymm.h.

◆ asymm_rounding_half_sum3()

int3 asymm_rounding_half_sum3 ( int3  a,
int3  b 
)
inline

Definition at line 517 of file helpers_asymm.h.

◆ asymm_rounding_half_sum4()

int4 asymm_rounding_half_sum4 ( int4  a,
int4  b 
)
inline

Definition at line 518 of file helpers_asymm.h.

◆ asymm_rounding_half_sum8()

int8 asymm_rounding_half_sum8 ( int8  a,
int8  b 
)
inline

Definition at line 519 of file helpers_asymm.h.

◆ asymm_saturating_rounding_mult_by_pow21()

int asymm_saturating_rounding_mult_by_pow21 ( int  x,
int  exponent 
)
inline

Definition at line 508 of file helpers_asymm.h.

◆ asymm_saturating_rounding_mult_by_pow216()

int16 asymm_saturating_rounding_mult_by_pow216 ( int16  x,
int  exponent 
)
inline

Definition at line 513 of file helpers_asymm.h.

◆ asymm_saturating_rounding_mult_by_pow22()

int2 asymm_saturating_rounding_mult_by_pow22 ( int2  x,
int  exponent 
)
inline

Definition at line 509 of file helpers_asymm.h.

◆ asymm_saturating_rounding_mult_by_pow23()

int3 asymm_saturating_rounding_mult_by_pow23 ( int3  x,
int  exponent 
)
inline

Definition at line 510 of file helpers_asymm.h.

◆ asymm_saturating_rounding_mult_by_pow24()

int4 asymm_saturating_rounding_mult_by_pow24 ( int4  x,
int  exponent 
)
inline

Definition at line 511 of file helpers_asymm.h.

◆ asymm_saturating_rounding_mult_by_pow28()

int8 asymm_saturating_rounding_mult_by_pow28 ( int8  x,
int  exponent 
)
inline

Definition at line 512 of file helpers_asymm.h.

◆ asymm_select_using_mask1()

int asymm_select_using_mask1 ( int  if_mask,
int  then_val,
int  else_val 
)
inline

Definition at line 473 of file helpers_asymm.h.

◆ asymm_select_using_mask16()

int16 asymm_select_using_mask16 ( int16  if_mask,
int16  then_val,
int16  else_val 
)
inline

Definition at line 478 of file helpers_asymm.h.

◆ asymm_select_using_mask2()

int2 asymm_select_using_mask2 ( int2  if_mask,
int2  then_val,
int2  else_val 
)
inline

Definition at line 474 of file helpers_asymm.h.

◆ asymm_select_using_mask3()

int3 asymm_select_using_mask3 ( int3  if_mask,
int3  then_val,
int3  else_val 
)
inline

Definition at line 475 of file helpers_asymm.h.

◆ asymm_select_using_mask4()

int4 asymm_select_using_mask4 ( int4  if_mask,
int4  then_val,
int4  else_val 
)
inline

Definition at line 476 of file helpers_asymm.h.

◆ asymm_select_using_mask8()

int8 asymm_select_using_mask8 ( int8  if_mask,
int8  then_val,
int8  else_val 
)
inline

Definition at line 477 of file helpers_asymm.h.

◆ dequantize_char1()

float dequantize_char1 ( char  input,
float  offset,
float  scale 
)
inline

Definition at line 439 of file helpers_asymm.h.

◆ dequantize_char16()

float16 dequantize_char16 ( char16  input,
float  offset,
float  scale 
)
inline

Definition at line 446 of file helpers_asymm.h.

◆ dequantize_int1()

float dequantize_int1 ( int  input,
float  offset,
float  scale 
)
inline

Definition at line 441 of file helpers_asymm.h.

◆ dequantize_int16()

float16 dequantize_int16 ( int16  input,
float  offset,
float  scale 
)
inline

Definition at line 450 of file helpers_asymm.h.

◆ dequantize_qasymm8()

float dequantize_qasymm8 ( uchar  input,
float  offset,
float  scale 
)
inline

Dequantize a scalar value from 8-bit asymmetric to floating-point.

Parameters
[in]inputInput value to quantize
[in]offsetQuantization offset
[in]scaleQuantization scale
Returns
quantized value

Definition at line 62 of file helpers_asymm.h.

References arm_compute::test::validation::scale.

63 {
64  return ((float)input - offset) * scale;
65 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:846

◆ dequantize_qasymm8_signed()

float dequantize_qasymm8_signed ( char  input,
float  offset,
float  scale 
)
inline

Dequantize a scalar value from signed 8-bit asymmetric to floating-point.

Parameters
[in]inputInput value to quantize
[in]offsetQuantization offset
[in]scaleQuantization scale
Returns
quantized value

Definition at line 75 of file helpers_asymm.h.

References arm_compute::test::validation::scale.

76 {
77  return ((float)input - offset) * scale;
78 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:846

◆ dequantize_short16()

float16 dequantize_short16 ( short16  input,
float  offset,
float  scale 
)
inline

Definition at line 448 of file helpers_asymm.h.

◆ dequantize_short4()

float4 dequantize_short4 ( short4  input,
float  offset,
float  scale 
)
inline

Definition at line 444 of file helpers_asymm.h.

◆ dequantize_uchar1()

float dequantize_uchar1 ( uchar  input,
float  offset,
float  scale 
)
inline

Definition at line 438 of file helpers_asymm.h.

◆ dequantize_uchar16()

float16 dequantize_uchar16 ( uchar16  input,
float  offset,
float  scale 
)
inline

Definition at line 445 of file helpers_asymm.h.

◆ dequantize_uchar4()

float4 dequantize_uchar4 ( uchar4  input,
float  offset,
float  scale 
)
inline

Definition at line 442 of file helpers_asymm.h.

◆ dequantize_uint1()

float dequantize_uint1 ( uint  input,
float  offset,
float  scale 
)
inline

Definition at line 440 of file helpers_asymm.h.

◆ dequantize_uint16()

float16 dequantize_uint16 ( uint16  input,
float  offset,
float  scale 
)
inline

Definition at line 449 of file helpers_asymm.h.

◆ dequantize_ushort16()

float16 dequantize_ushort16 ( ushort16  input,
float  offset,
float  scale 
)
inline

Definition at line 447 of file helpers_asymm.h.

◆ dequantize_ushort4()

float4 dequantize_ushort4 ( ushort4  input,
float  offset,
float  scale 
)
inline

Definition at line 443 of file helpers_asymm.h.

◆ exp_barrel_shifter1()

int exp_barrel_shifter1 ( int  result,
int  exponent,
int  fp_multiplier,
int  k_integer_bits,
int  k_fractional_bits,
int  remainder 
)
inline

Definition at line 494 of file helpers_asymm.h.

◆ exp_barrel_shifter16()

int16 exp_barrel_shifter16 ( int16  result,
int  exponent,
int  fp_multiplier,
int  k_integer_bits,
int  k_fractional_bits,
int16  remainder 
)
inline

Definition at line 499 of file helpers_asymm.h.

◆ exp_barrel_shifter2()

int2 exp_barrel_shifter2 ( int2  result,
int  exponent,
int  fp_multiplier,
int  k_integer_bits,
int  k_fractional_bits,
int2  remainder 
)
inline

Definition at line 495 of file helpers_asymm.h.

◆ exp_barrel_shifter3()

int3 exp_barrel_shifter3 ( int3  result,
int  exponent,
int  fp_multiplier,
int  k_integer_bits,
int  k_fractional_bits,
int3  remainder 
)
inline

Definition at line 496 of file helpers_asymm.h.

◆ exp_barrel_shifter4()

int4 exp_barrel_shifter4 ( int4  result,
int  exponent,
int  fp_multiplier,
int  k_integer_bits,
int  k_fractional_bits,
int4  remainder 
)
inline

Definition at line 497 of file helpers_asymm.h.

◆ exp_barrel_shifter8()

int8 exp_barrel_shifter8 ( int8  result,
int  exponent,
int  fp_multiplier,
int  k_integer_bits,
int  k_fractional_bits,
int8  remainder 
)
inline

Definition at line 498 of file helpers_asymm.h.

◆ multiply_by_quantized_multiplier1()

int multiply_by_quantized_multiplier1 ( int  input,
int  qmul,
int  shift 
)
inline

Definition at line 536 of file helpers_asymm.h.

◆ multiply_by_quantized_multiplier16()

int16 multiply_by_quantized_multiplier16 ( int16  input,
int  qmul,
int  shift 
)
inline

Definition at line 541 of file helpers_asymm.h.

◆ multiply_by_quantized_multiplier2()

int2 multiply_by_quantized_multiplier2 ( int2  input,
int  qmul,
int  shift 
)
inline

Definition at line 537 of file helpers_asymm.h.

◆ multiply_by_quantized_multiplier3()

int3 multiply_by_quantized_multiplier3 ( int3  input,
int  qmul,
int  shift 
)
inline

Definition at line 538 of file helpers_asymm.h.

◆ multiply_by_quantized_multiplier4()

int4 multiply_by_quantized_multiplier4 ( int4  input,
int  qmul,
int  shift 
)
inline

Definition at line 539 of file helpers_asymm.h.

◆ multiply_by_quantized_multiplier8()

int8 multiply_by_quantized_multiplier8 ( int8  input,
int  qmul,
int  shift 
)
inline

Definition at line 540 of file helpers_asymm.h.

◆ quantize_char1()

char quantize_char1 ( float  input,
float  offset,
float  scale 
)
inline

Definition at line 425 of file helpers_asymm.h.

◆ quantize_char16()

char16 quantize_char16 ( float16  input,
float  offset,
float  scale 
)
inline

Definition at line 432 of file helpers_asymm.h.

◆ quantize_int1()

int quantize_int1 ( float  input,
float  offset,
float  scale 
)
inline

Definition at line 427 of file helpers_asymm.h.

◆ quantize_int16()

int16 quantize_int16 ( float16  input,
float  offset,
float  scale 
)
inline

Definition at line 436 of file helpers_asymm.h.

◆ quantize_qasymm8()

uchar quantize_qasymm8 ( float  input,
float  offset,
float  scale 
)
inline

Quantize a floating-point scalar value to 8-bit asymmetric.

Parameters
[in]inputInput value to quantize
[in]offsetQuantization offset
[in]scaleQuantization scale
Returns
quantized value

Definition at line 47 of file helpers_asymm.h.

References CONVERT_DOWN_RTE, CONVERT_SAT, and offset().

48 {
49  float out_f32 = input / scale + offset;
50  uchar res_u8 = CONVERT_SAT(CONVERT_DOWN_RTE(out_f32, int), uchar);
51  return res_u8;
52 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:846
#define CONVERT_SAT(a, b)
#define CONVERT_DOWN_RTE(x, type)
Definition: helpers_asymm.h:37

◆ quantize_short16()

short16 quantize_short16 ( float16  input,
float  offset,
float  scale 
)
inline

Definition at line 434 of file helpers_asymm.h.

◆ quantize_short4()

short4 quantize_short4 ( float4  input,
float  offset,
float  scale 
)
inline

Definition at line 430 of file helpers_asymm.h.

◆ quantize_uchar1()

uchar quantize_uchar1 ( float  input,
float  offset,
float  scale 
)
inline

Definition at line 424 of file helpers_asymm.h.

◆ quantize_uchar16()

uchar16 quantize_uchar16 ( float16  input,
float  offset,
float  scale 
)
inline

Definition at line 431 of file helpers_asymm.h.

◆ quantize_uchar4()

uchar4 quantize_uchar4 ( float4  input,
float  offset,
float  scale 
)
inline

Definition at line 428 of file helpers_asymm.h.

◆ quantize_uint1()

uint quantize_uint1 ( float  input,
float  offset,
float  scale 
)
inline

Definition at line 426 of file helpers_asymm.h.

◆ quantize_uint16()

uint16 quantize_uint16 ( float16  input,
float  offset,
float  scale 
)
inline

Definition at line 435 of file helpers_asymm.h.

◆ quantize_ushort16()

ushort16 quantize_ushort16 ( float16  input,
float  offset,
float  scale 
)
inline

Definition at line 433 of file helpers_asymm.h.

◆ quantize_ushort4()

ushort4 quantize_ushort4 ( float4  input,
float  offset,
float  scale 
)
inline

Definition at line 429 of file helpers_asymm.h.