Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 1 | /* |
Sheri Zhang | ac6499a | 2021-02-10 15:32:38 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2021 Arm Limited. |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef ARM_COMPUTE_HELPERS_ASYMM_H |
| 25 | #define ARM_COMPUTE_HELPERS_ASYMM_H |
| 26 | |
| 27 | #include "helpers.h" |
| 28 | |
Sang-Hoon Park | bfd75d6 | 2019-10-30 14:56:17 +0000 | [diff] [blame] | 29 | /** Convert the given vector with round to nearest even rounding mode |
| 30 | * |
| 31 | * @param[in] x The target to be converted |
| 32 | * @param[in] type The target type |
| 33 | * |
| 34 | * @return The converted vector |
| 35 | */ |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 36 | #define CONVERT_DOWN_RTE_STR(x, type) (convert_##type##_rte((x))) |
| 37 | #define CONVERT_DOWN_RTE(x, type) CONVERT_DOWN_RTE_STR(x, type) |
| 38 | |
| 39 | /** Quantize a floating-point scalar value to 8-bit asymmetric |
| 40 | * |
| 41 | * @param[in] input Input value to quantize |
| 42 | * @param[in] offset Quantization offset |
| 43 | * @param[in] scale Quantization scale |
| 44 | * |
| 45 | * @return quantized value |
| 46 | */ |
| 47 | inline uchar quantize_qasymm8(float input, float offset, float scale) |
| 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 | } |
| 53 | |
| 54 | /** Dequantize a scalar value from 8-bit asymmetric to floating-point |
| 55 | * |
| 56 | * @param[in] input Input value to quantize |
| 57 | * @param[in] offset Quantization offset |
| 58 | * @param[in] scale Quantization scale |
| 59 | * |
| 60 | * @return quantized value |
| 61 | */ |
| 62 | inline float dequantize_qasymm8(uchar input, float offset, float scale) |
| 63 | { |
| 64 | return ((float)input - offset) * scale; |
| 65 | } |
| 66 | |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 67 | /** Dequantize a scalar value from signed 8-bit asymmetric to floating-point |
| 68 | * |
| 69 | * @param[in] input Input value to quantize |
| 70 | * @param[in] offset Quantization offset |
| 71 | * @param[in] scale Quantization scale |
| 72 | * |
| 73 | * @return quantized value |
| 74 | */ |
| 75 | inline float dequantize_qasymm8_signed(char input, float offset, float scale) |
| 76 | { |
| 77 | return ((float)input - offset) * scale; |
| 78 | } |
| 79 | |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 80 | /** Quantize a vector of values from floating-point |
| 81 | * |
| 82 | * @param[in] type Output data type. |
| 83 | * @param[in] size Size of vector. |
| 84 | * |
| 85 | * @return quantized values |
| 86 | */ |
| 87 | #define QUANTIZE_IMPL(type, size) \ |
| 88 | inline VEC_DATA_TYPE(type, size) quantize_##type##size(VEC_DATA_TYPE(float, size) input, float offset, float scale) \ |
| 89 | { \ |
| 90 | VEC_DATA_TYPE(float, size) \ |
| 91 | out_f32 = input / (VEC_DATA_TYPE(float, size))(scale) + (VEC_DATA_TYPE(float, size))(offset); \ |
| 92 | VEC_DATA_TYPE(type, size) \ |
| 93 | res = CONVERT_SAT(CONVERT_DOWN_RTE(out_f32, VEC_DATA_TYPE(int, size)), VEC_DATA_TYPE(type, size)); \ |
| 94 | return res; \ |
| 95 | } |
| 96 | |
| 97 | /** Dequantize a vector of values to floating-point |
| 98 | * |
| 99 | * @param[in] type Input data type. |
| 100 | * @param[in] size Size of vector. |
| 101 | * |
| 102 | * @return dequantized values in floating point |
| 103 | */ |
| 104 | #define DEQUANTIZE_IMPL(type, size) \ |
| 105 | inline VEC_DATA_TYPE(float, size) dequantize_##type##size(VEC_DATA_TYPE(type, size) input, float offset, float scale) \ |
| 106 | { \ |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 107 | return (CONVERT(input, VEC_DATA_TYPE(float, size)) - offset) * scale; \ |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 108 | } |
| 109 | |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 110 | /** Correctly-rounded-to-nearest division by a power-of-two. |
| 111 | * |
| 112 | * @param[in] size Size of vector. |
| 113 | * |
| 114 | * @return Correctly-rounded-to-nearest division by a power-of-two. |
| 115 | */ |
Michele Di Giorgio | df4cf57 | 2019-10-09 15:32:39 +0100 | [diff] [blame] | 116 | #define ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(size) \ |
| 117 | inline VEC_DATA_TYPE(int, size) asymm_rounding_divide_by_POW2_##size(VEC_DATA_TYPE(int, size) x, VEC_DATA_TYPE(int, size) exponent) \ |
| 118 | { \ |
| 119 | const VEC_DATA_TYPE(int, size) \ |
| 120 | zero = (VEC_DATA_TYPE(int, size))0; \ |
| 121 | const VEC_DATA_TYPE(int, size) \ |
| 122 | one = (VEC_DATA_TYPE(int, size))1; \ |
| 123 | VEC_DATA_TYPE(int, size) \ |
| 124 | mask = (one << exponent) - one; \ |
| 125 | VEC_DATA_TYPE(int, size) \ |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 126 | threshold = (mask >> 1) + select(zero, one, (SELECT_VEC_DATA_TYPE(int, size))(x < 0)); \ |
| 127 | return (x >> exponent) + select(zero, one, (SELECT_VEC_DATA_TYPE(int, size))((x & mask) > threshold)); \ |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 128 | } |
| 129 | |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 130 | /** Product of two numbers, interpreting them as fixed-point values in the interval [-1, 1), |
| 131 | * rounding to the nearest value, and saturating -1 * -1 to the maximum value. |
| 132 | * |
| 133 | * @param[in] size Size of vector. |
| 134 | * |
| 135 | * @return Product of two fixed-point numbers. |
| 136 | */ |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 137 | #define ASYMM_MULT_IMPL(size) \ |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 138 | inline VEC_DATA_TYPE(int, size) asymm_mult##size(VEC_DATA_TYPE(int, size) a, VEC_DATA_TYPE(int, size) b) \ |
| 139 | { \ |
| 140 | VEC_DATA_TYPE(int, size) \ |
| 141 | overflow = a == b && a == INT_MIN; \ |
| 142 | VEC_DATA_TYPE(long, size) \ |
| 143 | a_64 = convert_long##size(a); \ |
| 144 | VEC_DATA_TYPE(long, size) \ |
| 145 | b_64 = convert_long##size(b); \ |
| 146 | VEC_DATA_TYPE(long, size) \ |
| 147 | ab_64 = a_64 * b_64; \ |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 148 | /* Revert COMPMID-907 */ \ |
| 149 | VEC_DATA_TYPE(long, size) \ |
| 150 | mask1 = 1 << 30; \ |
| 151 | VEC_DATA_TYPE(long, size) \ |
| 152 | mask2 = 1 - (1 << 30); \ |
| 153 | VEC_DATA_TYPE(long, size) \ |
| 154 | is_positive_or_zero = ab_64 >= 0; \ |
| 155 | VEC_DATA_TYPE(long, size) \ |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 156 | nudge = select(mask2, mask1, (SELECT_VEC_DATA_TYPE(long, size))(is_positive_or_zero)); \ |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 157 | VEC_DATA_TYPE(long, size) \ |
| 158 | mask = 1ll << 31; \ |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 159 | VEC_DATA_TYPE(int, size) \ |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 160 | ab_x2_high32 = convert_int##size((ab_64 + nudge) / mask); \ |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 161 | return select(ab_x2_high32, INT_MAX, (SELECT_VEC_DATA_TYPE(int, size))(overflow)); \ |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 162 | } |
| 163 | |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 164 | /** Calculates \f$ exp(x) \f$ for x in [-1/4, 0). |
| 165 | * |
| 166 | * @param[in] size Size of vector. |
| 167 | * |
| 168 | * @return Result in fixed-point format Q0. |
| 169 | */ |
| 170 | #define ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(size) \ |
| 171 | inline VEC_DATA_TYPE(int, size) asymm_exp_on_interval_between_negative_one_quarter_and_0_excl##size(VEC_DATA_TYPE(int, size) a) \ |
| 172 | { \ |
| 173 | const VEC_DATA_TYPE(int, size) constant_term = 1895147668; \ |
| 174 | const VEC_DATA_TYPE(int, size) constant_1_over_3 = 715827883; \ |
| 175 | const int k_fractional_bits = 31; \ |
| 176 | VEC_DATA_TYPE(int, size) \ |
| 177 | x = a + (1 << (k_fractional_bits - 3)); \ |
| 178 | VEC_DATA_TYPE(int, size) \ |
| 179 | x2 = ASYMM_MULT(x, x, size); \ |
| 180 | VEC_DATA_TYPE(int, size) \ |
| 181 | x3 = ASYMM_MULT(x2, x, size); \ |
| 182 | VEC_DATA_TYPE(int, size) \ |
| 183 | x4 = ASYMM_MULT(x2, x2, size); \ |
| 184 | VEC_DATA_TYPE(int, size) \ |
| 185 | x4_over_4 = ASYMM_ROUNDING_DIVIDE_BY_POW2(x4, 2, size); \ |
| 186 | VEC_DATA_TYPE(int, size) \ |
| 187 | x4_over_24_plus_x3_over_6_plus_x2 = ASYMM_MULT((x4_over_4 + x3), constant_1_over_3, size) + x2; \ |
| 188 | VEC_DATA_TYPE(int, size) \ |
| 189 | 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); \ |
| 190 | return constant_term + ASYMM_MULT(constant_term, x + x4_over_24_plus_x3_over_6_plus_x2_over_2, size); \ |
| 191 | } |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 192 | |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 193 | /** Each bit of the result is set to the corresponding bit of either then_val or |
| 194 | * else_val depending on whether the corresponding bit of if_mask is set. |
Sheri Zhang | ac6499a | 2021-02-10 15:32:38 +0000 | [diff] [blame] | 195 | * Equivalent to the VBSL instruction in Arm Neon. |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 196 | * |
| 197 | * @param[in] size Size of vector. |
| 198 | * |
| 199 | * @returns Result contaning bits from @p then_val or from @p else_val depending on corresponding bit in @p if_mask is set or not. |
| 200 | */ |
| 201 | #define ASYMM_SELECT_USING_MASK_IMPL(size) \ |
| 202 | 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) \ |
| 203 | { \ |
| 204 | return (if_mask & then_val) ^ (~if_mask & else_val); \ |
| 205 | } |
| 206 | |
| 207 | /** For each element of input vector, the corresponding bits of the result item are set |
| 208 | * if the input item is zero. |
| 209 | * |
| 210 | * @param[in] size Size of vector. |
| 211 | * |
| 212 | * @returns Output vector with bits set when corresponding bit in @p a is zero. |
| 213 | */ |
| 214 | #define ASYMM_MASK_IF_ZERO_IMPL(size) \ |
| 215 | inline VEC_DATA_TYPE(int, size) asymm_mask_if_zero##size(VEC_DATA_TYPE(int, size) a) \ |
| 216 | { \ |
| 217 | const VEC_DATA_TYPE(int, size) all_zeros = 0; \ |
| 218 | const VEC_DATA_TYPE(int, size) all_ones = ~0; \ |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 219 | return select(all_zeros, all_ones, (SELECT_VEC_DATA_TYPE(int, size))(a == 0)); \ |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 220 | } |
| 221 | |
| 222 | /** For each element of input vector, the corresponding bits of the result item are set |
| 223 | * if the input item is non-zero. |
| 224 | * |
| 225 | * @param[in] size Size of vector. |
| 226 | * |
| 227 | * @returns Output vector with bits set when corresponding bit in @p a is non zero. |
| 228 | */ |
| 229 | #define ASYMM_MASK_IF_NON_ZERO_IMPL(size) \ |
| 230 | inline VEC_DATA_TYPE(int, size) asymm_mask_if_non_zero##size(VEC_DATA_TYPE(int, size) a) \ |
| 231 | { \ |
| 232 | const VEC_DATA_TYPE(int, size) all_zeros = 0; \ |
| 233 | const VEC_DATA_TYPE(int, size) all_ones = ~0; \ |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 234 | return select(all_zeros, all_ones, (SELECT_VEC_DATA_TYPE(int, size))(a != 0)); \ |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 235 | } |
| 236 | |
| 237 | #define EXP_BARREL_SHIFTER_IMPL(size) \ |
| 238 | 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) \ |
| 239 | { \ |
| 240 | if(k_integer_bits > exponent) \ |
| 241 | { \ |
| 242 | const int k_shift_amount = k_integer_bits > exponent ? k_fractional_bits + exponent : 0; \ |
| 243 | return ASYMM_SELECT_USING_MASK( \ |
| 244 | ASYMM_MASK_IF_NON_ZERO(remainder & (1 << k_shift_amount), size), \ |
| 245 | ASYMM_MULT(result, fp_multiplier, size), result, size); \ |
| 246 | } \ |
| 247 | \ |
| 248 | return result; \ |
| 249 | } |
| 250 | |
| 251 | /** Calculates \f$ exp(x) \f$ for x < 0. |
| 252 | * |
| 253 | * @param[in] size Size of vector. |
| 254 | * |
| 255 | * @return Result in fixed-point format Q0. |
| 256 | */ |
| 257 | #define ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(size) \ |
| 258 | inline VEC_DATA_TYPE(int, size) asymm_exp_on_negative_values##size(VEC_DATA_TYPE(int, size) a, int k_integer_bits) \ |
| 259 | { \ |
| 260 | const int k_fractional_bits = 31 - k_integer_bits; \ |
| 261 | VEC_DATA_TYPE(int, size) \ |
| 262 | k_one_quarter = 1 << (k_fractional_bits - 2); \ |
| 263 | VEC_DATA_TYPE(int, size) \ |
| 264 | mask = k_one_quarter - 1; \ |
| 265 | VEC_DATA_TYPE(int, size) \ |
| 266 | a_mod_quarter_minus_one_quarter = (a & mask) - k_one_quarter; \ |
| 267 | VEC_DATA_TYPE(int, size) \ |
| 268 | a_mod_quarter_minus_one_quarter_scaled = a_mod_quarter_minus_one_quarter << k_integer_bits; \ |
| 269 | VEC_DATA_TYPE(int, size) \ |
| 270 | result = ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL(a_mod_quarter_minus_one_quarter_scaled, size); \ |
| 271 | VEC_DATA_TYPE(int, size) \ |
| 272 | remainder = a_mod_quarter_minus_one_quarter - a; \ |
| 273 | \ |
| 274 | result = EXP_BARREL_SHIFTER(result, -2, 1672461947, k_integer_bits, k_fractional_bits, remainder, size); \ |
| 275 | result = EXP_BARREL_SHIFTER(result, -1, 1302514674, k_integer_bits, k_fractional_bits, remainder, size); \ |
| 276 | result = EXP_BARREL_SHIFTER(result, +0, 790015084, k_integer_bits, k_fractional_bits, remainder, size); \ |
| 277 | result = EXP_BARREL_SHIFTER(result, +1, 290630308, k_integer_bits, k_fractional_bits, remainder, size); \ |
| 278 | result = EXP_BARREL_SHIFTER(result, +2, 39332535, k_integer_bits, k_fractional_bits, remainder, size); \ |
| 279 | result = EXP_BARREL_SHIFTER(result, +3, 720401, k_integer_bits, k_fractional_bits, remainder, size); \ |
| 280 | result = EXP_BARREL_SHIFTER(result, +4, 242, k_integer_bits, k_fractional_bits, remainder, size); \ |
| 281 | \ |
| 282 | if(k_integer_bits > 5) \ |
| 283 | { \ |
| 284 | const VEC_DATA_TYPE(int, size) clamp = -(1 << (k_fractional_bits + 5)); \ |
| 285 | result = ASYMM_SELECT_USING_MASK(ASYMM_MASK_IF_NON_ZERO(a < clamp, size), 0, result, size); \ |
| 286 | } \ |
| 287 | \ |
| 288 | const VEC_DATA_TYPE(int, size) Q0_one = INT_MAX; \ |
| 289 | return ASYMM_SELECT_USING_MASK(ASYMM_MASK_IF_ZERO(a, size), Q0_one, result, size); \ |
| 290 | } |
| 291 | |
| 292 | /** Calculates the product of a integer value by a power of two, with either a positive exponent |
| 293 | * (equivalent to an arithmetic left shift, saturating) or a negative exponent |
| 294 | * (equivalent to an arithmetic right shift, rounding to nearest). |
| 295 | * |
| 296 | * @param[in] size Size of vector. |
| 297 | * |
| 298 | * @return Arithmetic left or right shift. |
| 299 | */ |
| 300 | #define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(size) \ |
| 301 | inline VEC_DATA_TYPE(int, size) asymm_saturating_rounding_mult_by_pow2##size(VEC_DATA_TYPE(int, size) x, int exponent) \ |
| 302 | { \ |
| 303 | if(exponent < 0) \ |
| 304 | { \ |
| 305 | return ASYMM_ROUNDING_DIVIDE_BY_POW2(x, -exponent, size); \ |
| 306 | } \ |
| 307 | \ |
| 308 | const VEC_DATA_TYPE(int, size) min = INT_MIN; \ |
| 309 | const VEC_DATA_TYPE(int, size) max = INT_MAX; \ |
| 310 | int threshold = ((1 << (31 - exponent)) - 1); \ |
| 311 | VEC_DATA_TYPE(int, size) \ |
| 312 | positive_mask = ASYMM_MASK_IF_NON_ZERO(x > threshold, size); \ |
| 313 | VEC_DATA_TYPE(int, size) \ |
| 314 | negative_mask = ASYMM_MASK_IF_NON_ZERO(x < -threshold, size); \ |
| 315 | VEC_DATA_TYPE(int, size) \ |
| 316 | result = x << exponent; \ |
| 317 | result = ASYMM_SELECT_USING_MASK(positive_mask, max, result, size); \ |
| 318 | result = ASYMM_SELECT_USING_MASK(negative_mask, min, result, size); \ |
| 319 | return result; \ |
| 320 | } |
| 321 | |
| 322 | /** Calculates (a+b)/2, rounded to the nearest integer. |
Sheri Zhang | ac6499a | 2021-02-10 15:32:38 +0000 | [diff] [blame] | 323 | * Equivalent to VRHADD in the Arm Neon instruction set. |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 324 | * |
| 325 | * @param[in] size Size of vector. |
| 326 | * |
| 327 | * @return (a+b)/2, rounded to the nearest integer. |
| 328 | */ |
| 329 | #define ASYMM_ROUNDING_HALF_SUM_IMPL(size) \ |
| 330 | inline VEC_DATA_TYPE(int, size) asymm_rounding_half_sum##size(VEC_DATA_TYPE(int, size) a, VEC_DATA_TYPE(int, size) b) \ |
| 331 | { \ |
| 332 | VEC_DATA_TYPE(long, size) \ |
| 333 | a64 = convert_long##size(a); \ |
| 334 | VEC_DATA_TYPE(long, size) \ |
| 335 | b64 = convert_long##size(b); \ |
| 336 | VEC_DATA_TYPE(long, size) \ |
| 337 | sum = a64 + b64; \ |
| 338 | const VEC_DATA_TYPE(long, size) one = 1; \ |
| 339 | const VEC_DATA_TYPE(long, size) minus_one = -1; \ |
| 340 | VEC_DATA_TYPE(long, size) \ |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 341 | sign = select(minus_one, one, (SELECT_VEC_DATA_TYPE(long, size))(sum >= 0)); \ |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 342 | return convert_int##size((sum + sign) / 2); \ |
| 343 | } |
| 344 | |
| 345 | /** Calculates \f$ 1 / (1 + x) \f$ for x in (0, 1). |
| 346 | * |
| 347 | * @param[in] size Size of vector. |
| 348 | * |
| 349 | * @return Result in fixed-point format Q0. |
| 350 | */ |
| 351 | #define ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(size) \ |
| 352 | inline VEC_DATA_TYPE(int, size) asymm_one_over_one_plus_x_for_x_in_0_1##size(VEC_DATA_TYPE(int, size) a) \ |
| 353 | { \ |
| 354 | const VEC_DATA_TYPE(int, size) Q0_one = INT_MAX; \ |
| 355 | const VEC_DATA_TYPE(int, size) Q2_one = 1 << (31 - 2); \ |
| 356 | VEC_DATA_TYPE(int, size) \ |
| 357 | half_denominator = ASYMM_ROUNDING_HALF_SUM(a, Q0_one, size); \ |
| 358 | const VEC_DATA_TYPE(int, size) Q2_48_over_17 = 1515870810; \ |
| 359 | const VEC_DATA_TYPE(int, size) Q2_neg_32_over_17 = -1010580540; \ |
| 360 | VEC_DATA_TYPE(int, size) \ |
| 361 | x = Q2_48_over_17 + ASYMM_MULT(half_denominator, Q2_neg_32_over_17, size); \ |
| 362 | for(int i = 0; i < 3; i++) \ |
| 363 | { \ |
| 364 | VEC_DATA_TYPE(int, size) \ |
| 365 | half_denominator_times_x = ASYMM_MULT(half_denominator, x, size); \ |
| 366 | VEC_DATA_TYPE(int, size) \ |
| 367 | one_minus_half_denominator_times_x = Q2_one - half_denominator_times_x; \ |
| 368 | VEC_DATA_TYPE(int, size) \ |
| 369 | tmp = ASYMM_MULT(x, one_minus_half_denominator_times_x, size); \ |
| 370 | x = x + ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(tmp, 2, size); \ |
| 371 | } \ |
| 372 | return ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(x, 1, size); \ |
| 373 | } |
| 374 | |
| 375 | /** Considering the integer value as fixed-point, change the number of integer bits and update value accordingly. |
| 376 | * |
| 377 | * @param[in] size Size of vector. |
| 378 | * |
| 379 | * @return Rescaled value. |
| 380 | */ |
| 381 | #define ASYMM_RESCALE_IMPL(size) \ |
| 382 | inline VEC_DATA_TYPE(int, size) asymm_rescale##size(VEC_DATA_TYPE(int, size) value, int src_integer_bits, int dst_integer_bits) \ |
| 383 | { \ |
| 384 | int exponent = src_integer_bits - dst_integer_bits; \ |
| 385 | return ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(value, exponent, size); \ |
| 386 | } |
| 387 | |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 388 | #define QUANTIZE_STR(input, offset, scale, type, size) quantize_##type##size(input, offset, scale) |
| 389 | #define QUANTIZE(input, offset, scale, type, size) QUANTIZE_STR(input, offset, scale, type, size) |
| 390 | #define DEQUANTIZE_STR(input, offset, scale, type, size) dequantize_##type##size(input, offset, scale) |
| 391 | #define DEQUANTIZE(input, offset, scale, type, size) DEQUANTIZE_STR(input, offset, scale, type, size) |
| 392 | |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 393 | #define ASYMM_ROUNDING_DIVIDE_BY_POW2_STR(x, exponent, size) asymm_rounding_divide_by_POW2_##size(x, exponent) |
| 394 | #define ASYMM_ROUNDING_DIVIDE_BY_POW2(x, exponent, size) ASYMM_ROUNDING_DIVIDE_BY_POW2_STR(x, exponent, size) |
| 395 | #define ASYMM_MULT_STR(a, b, size) asymm_mult##size(a, b) |
| 396 | #define ASYMM_MULT(a, b, size) ASYMM_MULT_STR(a, b, size) |
Michele Di Giorgio | 14cbfb2 | 2019-10-23 10:53:10 +0100 | [diff] [blame] | 397 | #define ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE(x, quantized_multiplier, left_shift, size) \ |
| 398 | ASYMM_MULT(x *((VEC_DATA_TYPE(int, size))(1) << (-left_shift)), quantized_multiplier, size) |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 399 | #define ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE(x, quantized_multiplier, right_shift, size) \ |
| 400 | ASYMM_ROUNDING_DIVIDE_BY_POW2(ASYMM_MULT(x, quantized_multiplier, size), right_shift, size) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 401 | #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) |
| 402 | #define ASYMM_SELECT_USING_MASK(if_mask, then_val, else_val, size) asymm_select_using_mask##size(if_mask, then_val, else_val) |
| 403 | #define ASYMM_MASK_IF_ZERO(a, size) asymm_mask_if_zero##size(a) |
| 404 | #define ASYMM_MASK_IF_NON_ZERO(a, size) asymm_mask_if_non_zero##size(a) |
| 405 | #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) |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 406 | #define ASYMM_EXP_ON_NEGATIVE_VALUES_STR(a, k_integer_bits, size) asymm_exp_on_negative_values##size(a, k_integer_bits) |
| 407 | #define ASYMM_EXP_ON_NEGATIVE_VALUES(a, k_integer_bits, size) ASYMM_EXP_ON_NEGATIVE_VALUES_STR(a, k_integer_bits, size) |
| 408 | #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) |
| 409 | #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) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 410 | #define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(x, exponent, size) asymm_saturating_rounding_mult_by_pow2##size(x, exponent) |
| 411 | #define ASYMM_ROUNDING_HALF_SUM(a, b, size) asymm_rounding_half_sum##size(a, b) |
Giorgio Arena | 2d1a835 | 2020-10-26 15:04:08 +0000 | [diff] [blame] | 412 | #define ASYMM_RESCALE_STR(value, src_integer_bits, dst_integer_bits, size) asymm_rescale##size(value, src_integer_bits, dst_integer_bits) |
| 413 | #define ASYMM_RESCALE(value, src_integer_bits, dst_integer_bits, size) ASYMM_RESCALE_STR(value, src_integer_bits, dst_integer_bits, size) |
Chunosov | d621bca | 2017-11-03 17:33:15 +0700 | [diff] [blame] | 414 | |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 415 | #define MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL(size) \ |
| 416 | inline VEC_DATA_TYPE(int, size) multiply_by_quantized_multiplier##size(VEC_DATA_TYPE(int, size) input, int qmul, int shift) \ |
| 417 | { \ |
| 418 | const int left_shift = shift > 0 ? shift : 0; \ |
| 419 | const int right_shift = shift > 0 ? 0 : -shift; \ |
| 420 | return ASYMM_ROUNDING_DIVIDE_BY_POW2(ASYMM_MULT(input * (1 << left_shift), qmul, size), right_shift, size); \ |
| 421 | } |
| 422 | #define MULTIPLY_BY_QUANTIZED_MULTIPLIER(input, qmul, shift, size) multiply_by_quantized_multiplier##size(input, qmul, shift) |
| 423 | |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 424 | QUANTIZE_IMPL(uchar, 1) |
| 425 | QUANTIZE_IMPL(char, 1) |
Michalis Spyrou | 0b18d97 | 2020-01-30 18:11:13 +0000 | [diff] [blame] | 426 | QUANTIZE_IMPL(uint, 1) |
| 427 | QUANTIZE_IMPL(int, 1) |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 428 | QUANTIZE_IMPL(uchar, 4) |
| 429 | QUANTIZE_IMPL(ushort, 4) |
Michele Di Giorgio | 6b612f5 | 2019-09-05 12:30:22 +0100 | [diff] [blame] | 430 | QUANTIZE_IMPL(short, 4) |
Michalis Spyrou | 0b18d97 | 2020-01-30 18:11:13 +0000 | [diff] [blame] | 431 | QUANTIZE_IMPL(uchar, 16) |
| 432 | QUANTIZE_IMPL(char, 16) |
| 433 | QUANTIZE_IMPL(ushort, 16) |
| 434 | QUANTIZE_IMPL(short, 16) |
| 435 | QUANTIZE_IMPL(uint, 16) |
| 436 | QUANTIZE_IMPL(int, 16) |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 437 | |
Manuel Bottini | 8481d83 | 2019-12-10 15:28:40 +0000 | [diff] [blame] | 438 | DEQUANTIZE_IMPL(uchar, 1) |
| 439 | DEQUANTIZE_IMPL(char, 1) |
Michalis Spyrou | 0b18d97 | 2020-01-30 18:11:13 +0000 | [diff] [blame] | 440 | DEQUANTIZE_IMPL(uint, 1) |
| 441 | DEQUANTIZE_IMPL(int, 1) |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 442 | DEQUANTIZE_IMPL(uchar, 4) |
| 443 | DEQUANTIZE_IMPL(ushort, 4) |
Michele Di Giorgio | 6b612f5 | 2019-09-05 12:30:22 +0100 | [diff] [blame] | 444 | DEQUANTIZE_IMPL(short, 4) |
Michalis Spyrou | 0b18d97 | 2020-01-30 18:11:13 +0000 | [diff] [blame] | 445 | DEQUANTIZE_IMPL(uchar, 16) |
| 446 | DEQUANTIZE_IMPL(char, 16) |
| 447 | DEQUANTIZE_IMPL(ushort, 16) |
| 448 | DEQUANTIZE_IMPL(short, 16) |
| 449 | DEQUANTIZE_IMPL(uint, 16) |
| 450 | DEQUANTIZE_IMPL(int, 16) |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 451 | |
Michele Di Giorgio | a046e16 | 2019-10-08 09:36:26 +0100 | [diff] [blame] | 452 | ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 453 | ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 454 | ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 455 | ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(4) |
| 456 | ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(8) |
| 457 | ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(16) |
| 458 | |
Michele Di Giorgio | a046e16 | 2019-10-08 09:36:26 +0100 | [diff] [blame] | 459 | ASYMM_MULT_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 460 | ASYMM_MULT_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 461 | ASYMM_MULT_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 462 | ASYMM_MULT_IMPL(4) |
| 463 | ASYMM_MULT_IMPL(8) |
| 464 | ASYMM_MULT_IMPL(16) |
| 465 | |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 466 | ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 467 | ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 468 | ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 469 | ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(4) |
| 470 | ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(8) |
| 471 | ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(16) |
| 472 | |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 473 | ASYMM_SELECT_USING_MASK_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 474 | ASYMM_SELECT_USING_MASK_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 475 | ASYMM_SELECT_USING_MASK_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 476 | ASYMM_SELECT_USING_MASK_IMPL(4) |
| 477 | ASYMM_SELECT_USING_MASK_IMPL(8) |
| 478 | ASYMM_SELECT_USING_MASK_IMPL(16) |
| 479 | |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 480 | ASYMM_MASK_IF_ZERO_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 481 | ASYMM_MASK_IF_ZERO_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 482 | ASYMM_MASK_IF_ZERO_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 483 | ASYMM_MASK_IF_ZERO_IMPL(4) |
| 484 | ASYMM_MASK_IF_ZERO_IMPL(8) |
| 485 | ASYMM_MASK_IF_ZERO_IMPL(16) |
| 486 | |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 487 | ASYMM_MASK_IF_NON_ZERO_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 488 | ASYMM_MASK_IF_NON_ZERO_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 489 | ASYMM_MASK_IF_NON_ZERO_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 490 | ASYMM_MASK_IF_NON_ZERO_IMPL(4) |
| 491 | ASYMM_MASK_IF_NON_ZERO_IMPL(8) |
| 492 | ASYMM_MASK_IF_NON_ZERO_IMPL(16) |
| 493 | |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 494 | EXP_BARREL_SHIFTER_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 495 | EXP_BARREL_SHIFTER_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 496 | EXP_BARREL_SHIFTER_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 497 | EXP_BARREL_SHIFTER_IMPL(4) |
| 498 | EXP_BARREL_SHIFTER_IMPL(8) |
| 499 | EXP_BARREL_SHIFTER_IMPL(16) |
| 500 | |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 501 | ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 502 | ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 503 | ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 504 | ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(4) |
| 505 | ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(8) |
| 506 | ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(16) |
| 507 | |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 508 | ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 509 | ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 510 | ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 511 | ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(4) |
| 512 | ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(8) |
| 513 | ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(16) |
| 514 | |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 515 | ASYMM_ROUNDING_HALF_SUM_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 516 | ASYMM_ROUNDING_HALF_SUM_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 517 | ASYMM_ROUNDING_HALF_SUM_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 518 | ASYMM_ROUNDING_HALF_SUM_IMPL(4) |
| 519 | ASYMM_ROUNDING_HALF_SUM_IMPL(8) |
| 520 | ASYMM_ROUNDING_HALF_SUM_IMPL(16) |
| 521 | |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 522 | ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 523 | ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 524 | ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 525 | ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(4) |
| 526 | ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(8) |
| 527 | ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(16) |
| 528 | |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 529 | ASYMM_RESCALE_IMPL(1) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 530 | ASYMM_RESCALE_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 531 | ASYMM_RESCALE_IMPL(3) |
Giorgio Arena | b99f00d | 2018-02-14 10:40:16 +0000 | [diff] [blame] | 532 | ASYMM_RESCALE_IMPL(4) |
| 533 | ASYMM_RESCALE_IMPL(8) |
| 534 | ASYMM_RESCALE_IMPL(16) |
| 535 | |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 536 | MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL(1) |
| 537 | MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL(2) |
Michele Di Giorgio | 671d4f0 | 2020-10-14 12:26:51 +0100 | [diff] [blame] | 538 | MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL(3) |
Sheri Zhang | b18252d | 2020-04-07 11:04:57 +0100 | [diff] [blame] | 539 | MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL(4) |
| 540 | MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL(8) |
| 541 | MULTIPLY_BY_QUANTIZED_MULTIPLIER_IMPL(16) |
| 542 | |
Michele Di Giorgio | 4aff98f | 2019-08-28 16:27:26 +0100 | [diff] [blame] | 543 | #endif // ARM_COMPUTE_HELPERS_ASYMM_H |