24 #ifndef ARM_COMPUTE_TEST_VALIDATION_UTILS_QUANTIZED_ASYMM_H 25 #define ARM_COMPUTE_TEST_VALIDATION_UTILS_QUANTIZED_ASYMM_H 38 const int32_t mask = (1 << exponent) - 1;
39 const int32_t
threshold = (mask >> 1) + (x < 0 ? 1 : 0);
40 return (x >> exponent) + ((x & mask) > threshold ? 1 : 0);
46 bool overflow = a == b && a == std::numeric_limits<int32_t>::min();
49 int64_t ab_64 = a_64 * b_64;
50 int32_t nudge = ab_64 >= 0 ? (1 << 30) : (1 - (1 << 30));
51 int32_t ab_x2_high32 =
static_cast<int32_t
>((ab_64 + nudge) / (1ll << 31));
52 return overflow ? std::numeric_limits<int32_t>::max() : ab_x2_high32;
57 int32_t result_offset_after_shift, int32_t min, int32_t max)
62 res =
asymm_int_mult(val * (1 << (-result_shift)), result_mult_int);
68 res += result_offset_after_shift;
69 res = utility::clamp<int32_t>(res, min, max);
int32_t asymm_rounding_divide_by_pow2(int32_t x, int exponent)
Rounded to nearest division by a power-of-two.
Copyright (c) 2017-2021 Arm Limited.
int32_t asymm_int_mult(int32_t a, int32_t b)
Multiplication of two integers.
int32_t quantize_down_scale_by_fixedpoint(int32_t val, int32_t result_mult_int, int32_t result_shift, int32_t result_offset_after_shift, int32_t min, int32_t max)
Quantize down the input value in range [min, max].
SimpleTensor< T > threshold(const SimpleTensor< T > &src, T threshold, T false_value, T true_value, ThresholdType type, T upper)