blob: 6377dbadb1dd923c4fa850d52041ebf0a51528fd [file] [log] [blame]
Chunosovd621bca2017-11-03 17:33:15 +07001/*
Manuel Bottini8481d832019-12-10 15:28:40 +00002 * Copyright (c) 2017-2020 ARM Limited.
Chunosovd621bca2017-11-03 17:33:15 +07003 *
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 Parkbfd75d62019-10-30 14:56:17 +000029/** 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 Giorgio4aff98f2019-08-28 16:27:26 +010036#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 */
47inline 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 */
62inline float dequantize_qasymm8(uchar input, float offset, float scale)
63{
64 return ((float)input - offset) * scale;
65}
66
Manuel Bottini8481d832019-12-10 15:28:40 +000067/** 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 */
75inline float dequantize_qasymm8_signed(char input, float offset, float scale)
76{
77 return ((float)input - offset) * scale;
78}
79
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +010080/** 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 Bottini8481d832019-12-10 15:28:40 +0000107 return (CONVERT(input, VEC_DATA_TYPE(float, size)) - offset) * scale; \
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100108 }
109
Chunosovd621bca2017-11-03 17:33:15 +0700110/** 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 Giorgiodf4cf572019-10-09 15:32:39 +0100116#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) \
126 threshold = (mask >> 1) + select(zero, one, x < 0); \
127 return (x >> exponent) + select(zero, one, (x & mask) > threshold); \
Chunosovd621bca2017-11-03 17:33:15 +0700128 }
129
Chunosovd621bca2017-11-03 17:33:15 +0700130/** 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 Arenab99f00d2018-02-14 10:40:16 +0000137#define ASYMM_MULT_IMPL(size) \
Chunosovd621bca2017-11-03 17:33:15 +0700138 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; \
Giorgio Arena6232d042018-02-12 14:46:00 +0000148 /* COMPMID-907 */ \
Giorgio Arenab99f00d2018-02-14 10:40:16 +0000149 VEC_DATA_TYPE(int, size) \
Giorgio Arena6232d042018-02-12 14:46:00 +0000150 ab_x2_high32 = convert_int##size(((ab_64 + (1 << 30)) >> 31)); \
Chunosovd621bca2017-11-03 17:33:15 +0700151 return select(ab_x2_high32, INT_MAX, overflow); \
152 }
153
Giorgio Arenab99f00d2018-02-14 10:40:16 +0000154/** Calculates \f$ exp(x) \f$ for x in [-1/4, 0).
155 *
156 * @param[in] size Size of vector.
157 *
158 * @return Result in fixed-point format Q0.
159 */
160#define ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(size) \
161 inline VEC_DATA_TYPE(int, size) asymm_exp_on_interval_between_negative_one_quarter_and_0_excl##size(VEC_DATA_TYPE(int, size) a) \
162 { \
163 const VEC_DATA_TYPE(int, size) constant_term = 1895147668; \
164 const VEC_DATA_TYPE(int, size) constant_1_over_3 = 715827883; \
165 const int k_fractional_bits = 31; \
166 VEC_DATA_TYPE(int, size) \
167 x = a + (1 << (k_fractional_bits - 3)); \
168 VEC_DATA_TYPE(int, size) \
169 x2 = ASYMM_MULT(x, x, size); \
170 VEC_DATA_TYPE(int, size) \
171 x3 = ASYMM_MULT(x2, x, size); \
172 VEC_DATA_TYPE(int, size) \
173 x4 = ASYMM_MULT(x2, x2, size); \
174 VEC_DATA_TYPE(int, size) \
175 x4_over_4 = ASYMM_ROUNDING_DIVIDE_BY_POW2(x4, 2, size); \
176 VEC_DATA_TYPE(int, size) \
177 x4_over_24_plus_x3_over_6_plus_x2 = ASYMM_MULT((x4_over_4 + x3), constant_1_over_3, size) + x2; \
178 VEC_DATA_TYPE(int, size) \
179 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); \
180 return constant_term + ASYMM_MULT(constant_term, x + x4_over_24_plus_x3_over_6_plus_x2_over_2, size); \
181 }
Chunosovd621bca2017-11-03 17:33:15 +0700182
Giorgio Arenab99f00d2018-02-14 10:40:16 +0000183/** Each bit of the result is set to the corresponding bit of either then_val or
184 * else_val depending on whether the corresponding bit of if_mask is set.
185 * Equivalent to the VBSL instruction in ARM NEON.
186 *
187 * @param[in] size Size of vector.
188 *
189 * @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.
190 */
191#define ASYMM_SELECT_USING_MASK_IMPL(size) \
192 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) \
193 { \
194 return (if_mask & then_val) ^ (~if_mask & else_val); \
195 }
196
197/** For each element of input vector, the corresponding bits of the result item are set
198 * if the input item is zero.
199 *
200 * @param[in] size Size of vector.
201 *
202 * @returns Output vector with bits set when corresponding bit in @p a is zero.
203 */
204#define ASYMM_MASK_IF_ZERO_IMPL(size) \
205 inline VEC_DATA_TYPE(int, size) asymm_mask_if_zero##size(VEC_DATA_TYPE(int, size) a) \
206 { \
207 const VEC_DATA_TYPE(int, size) all_zeros = 0; \
208 const VEC_DATA_TYPE(int, size) all_ones = ~0; \
209 return select(all_zeros, all_ones, a == 0); \
210 }
211
212/** For each element of input vector, the corresponding bits of the result item are set
213 * if the input item is non-zero.
214 *
215 * @param[in] size Size of vector.
216 *
217 * @returns Output vector with bits set when corresponding bit in @p a is non zero.
218 */
219#define ASYMM_MASK_IF_NON_ZERO_IMPL(size) \
220 inline VEC_DATA_TYPE(int, size) asymm_mask_if_non_zero##size(VEC_DATA_TYPE(int, size) a) \
221 { \
222 const VEC_DATA_TYPE(int, size) all_zeros = 0; \
223 const VEC_DATA_TYPE(int, size) all_ones = ~0; \
224 return select(all_zeros, all_ones, a != 0); \
225 }
226
227#define EXP_BARREL_SHIFTER_IMPL(size) \
228 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) \
229 { \
230 if(k_integer_bits > exponent) \
231 { \
232 const int k_shift_amount = k_integer_bits > exponent ? k_fractional_bits + exponent : 0; \
233 return ASYMM_SELECT_USING_MASK( \
234 ASYMM_MASK_IF_NON_ZERO(remainder & (1 << k_shift_amount), size), \
235 ASYMM_MULT(result, fp_multiplier, size), result, size); \
236 } \
237 \
238 return result; \
239 }
240
241/** Calculates \f$ exp(x) \f$ for x < 0.
242 *
243 * @param[in] size Size of vector.
244 *
245 * @return Result in fixed-point format Q0.
246 */
247#define ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(size) \
248 inline VEC_DATA_TYPE(int, size) asymm_exp_on_negative_values##size(VEC_DATA_TYPE(int, size) a, int k_integer_bits) \
249 { \
250 const int k_fractional_bits = 31 - k_integer_bits; \
251 VEC_DATA_TYPE(int, size) \
252 k_one_quarter = 1 << (k_fractional_bits - 2); \
253 VEC_DATA_TYPE(int, size) \
254 mask = k_one_quarter - 1; \
255 VEC_DATA_TYPE(int, size) \
256 a_mod_quarter_minus_one_quarter = (a & mask) - k_one_quarter; \
257 VEC_DATA_TYPE(int, size) \
258 a_mod_quarter_minus_one_quarter_scaled = a_mod_quarter_minus_one_quarter << k_integer_bits; \
259 VEC_DATA_TYPE(int, size) \
260 result = ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL(a_mod_quarter_minus_one_quarter_scaled, size); \
261 VEC_DATA_TYPE(int, size) \
262 remainder = a_mod_quarter_minus_one_quarter - a; \
263 \
264 result = EXP_BARREL_SHIFTER(result, -2, 1672461947, k_integer_bits, k_fractional_bits, remainder, size); \
265 result = EXP_BARREL_SHIFTER(result, -1, 1302514674, k_integer_bits, k_fractional_bits, remainder, size); \
266 result = EXP_BARREL_SHIFTER(result, +0, 790015084, k_integer_bits, k_fractional_bits, remainder, size); \
267 result = EXP_BARREL_SHIFTER(result, +1, 290630308, k_integer_bits, k_fractional_bits, remainder, size); \
268 result = EXP_BARREL_SHIFTER(result, +2, 39332535, k_integer_bits, k_fractional_bits, remainder, size); \
269 result = EXP_BARREL_SHIFTER(result, +3, 720401, k_integer_bits, k_fractional_bits, remainder, size); \
270 result = EXP_BARREL_SHIFTER(result, +4, 242, k_integer_bits, k_fractional_bits, remainder, size); \
271 \
272 if(k_integer_bits > 5) \
273 { \
274 const VEC_DATA_TYPE(int, size) clamp = -(1 << (k_fractional_bits + 5)); \
275 result = ASYMM_SELECT_USING_MASK(ASYMM_MASK_IF_NON_ZERO(a < clamp, size), 0, result, size); \
276 } \
277 \
278 const VEC_DATA_TYPE(int, size) Q0_one = INT_MAX; \
279 return ASYMM_SELECT_USING_MASK(ASYMM_MASK_IF_ZERO(a, size), Q0_one, result, size); \
280 }
281
282/** Calculates the product of a integer value by a power of two, with either a positive exponent
283 * (equivalent to an arithmetic left shift, saturating) or a negative exponent
284 * (equivalent to an arithmetic right shift, rounding to nearest).
285 *
286 * @param[in] size Size of vector.
287 *
288 * @return Arithmetic left or right shift.
289 */
290#define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(size) \
291 inline VEC_DATA_TYPE(int, size) asymm_saturating_rounding_mult_by_pow2##size(VEC_DATA_TYPE(int, size) x, int exponent) \
292 { \
293 if(exponent < 0) \
294 { \
295 return ASYMM_ROUNDING_DIVIDE_BY_POW2(x, -exponent, size); \
296 } \
297 \
298 const VEC_DATA_TYPE(int, size) min = INT_MIN; \
299 const VEC_DATA_TYPE(int, size) max = INT_MAX; \
300 int threshold = ((1 << (31 - exponent)) - 1); \
301 VEC_DATA_TYPE(int, size) \
302 positive_mask = ASYMM_MASK_IF_NON_ZERO(x > threshold, size); \
303 VEC_DATA_TYPE(int, size) \
304 negative_mask = ASYMM_MASK_IF_NON_ZERO(x < -threshold, size); \
305 VEC_DATA_TYPE(int, size) \
306 result = x << exponent; \
307 result = ASYMM_SELECT_USING_MASK(positive_mask, max, result, size); \
308 result = ASYMM_SELECT_USING_MASK(negative_mask, min, result, size); \
309 return result; \
310 }
311
312/** Calculates (a+b)/2, rounded to the nearest integer.
313 * Equivalent to VRHADD in the ARM NEON instruction set.
314 *
315 * @param[in] size Size of vector.
316 *
317 * @return (a+b)/2, rounded to the nearest integer.
318 */
319#define ASYMM_ROUNDING_HALF_SUM_IMPL(size) \
320 inline VEC_DATA_TYPE(int, size) asymm_rounding_half_sum##size(VEC_DATA_TYPE(int, size) a, VEC_DATA_TYPE(int, size) b) \
321 { \
322 VEC_DATA_TYPE(long, size) \
323 a64 = convert_long##size(a); \
324 VEC_DATA_TYPE(long, size) \
325 b64 = convert_long##size(b); \
326 VEC_DATA_TYPE(long, size) \
327 sum = a64 + b64; \
328 const VEC_DATA_TYPE(long, size) one = 1; \
329 const VEC_DATA_TYPE(long, size) minus_one = -1; \
330 VEC_DATA_TYPE(long, size) \
331 sign = select(minus_one, one, sum >= 0); \
332 return convert_int##size((sum + sign) / 2); \
333 }
334
335/** Calculates \f$ 1 / (1 + x) \f$ for x in (0, 1).
336 *
337 * @param[in] size Size of vector.
338 *
339 * @return Result in fixed-point format Q0.
340 */
341#define ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(size) \
342 inline VEC_DATA_TYPE(int, size) asymm_one_over_one_plus_x_for_x_in_0_1##size(VEC_DATA_TYPE(int, size) a) \
343 { \
344 const VEC_DATA_TYPE(int, size) Q0_one = INT_MAX; \
345 const VEC_DATA_TYPE(int, size) Q2_one = 1 << (31 - 2); \
346 VEC_DATA_TYPE(int, size) \
347 half_denominator = ASYMM_ROUNDING_HALF_SUM(a, Q0_one, size); \
348 const VEC_DATA_TYPE(int, size) Q2_48_over_17 = 1515870810; \
349 const VEC_DATA_TYPE(int, size) Q2_neg_32_over_17 = -1010580540; \
350 VEC_DATA_TYPE(int, size) \
351 x = Q2_48_over_17 + ASYMM_MULT(half_denominator, Q2_neg_32_over_17, size); \
352 for(int i = 0; i < 3; i++) \
353 { \
354 VEC_DATA_TYPE(int, size) \
355 half_denominator_times_x = ASYMM_MULT(half_denominator, x, size); \
356 VEC_DATA_TYPE(int, size) \
357 one_minus_half_denominator_times_x = Q2_one - half_denominator_times_x; \
358 VEC_DATA_TYPE(int, size) \
359 tmp = ASYMM_MULT(x, one_minus_half_denominator_times_x, size); \
360 x = x + ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(tmp, 2, size); \
361 } \
362 return ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(x, 1, size); \
363 }
364
365/** Considering the integer value as fixed-point, change the number of integer bits and update value accordingly.
366 *
367 * @param[in] size Size of vector.
368 *
369 * @return Rescaled value.
370 */
371#define ASYMM_RESCALE_IMPL(size) \
372 inline VEC_DATA_TYPE(int, size) asymm_rescale##size(VEC_DATA_TYPE(int, size) value, int src_integer_bits, int dst_integer_bits) \
373 { \
374 int exponent = src_integer_bits - dst_integer_bits; \
375 return ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(value, exponent, size); \
376 }
377
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100378#define QUANTIZE_STR(input, offset, scale, type, size) quantize_##type##size(input, offset, scale)
379#define QUANTIZE(input, offset, scale, type, size) QUANTIZE_STR(input, offset, scale, type, size)
380#define DEQUANTIZE_STR(input, offset, scale, type, size) dequantize_##type##size(input, offset, scale)
381#define DEQUANTIZE(input, offset, scale, type, size) DEQUANTIZE_STR(input, offset, scale, type, size)
382
Giorgio Arenab99f00d2018-02-14 10:40:16 +0000383#define ASYMM_ROUNDING_DIVIDE_BY_POW2(x, exponent, size) asymm_rounding_divide_by_POW2_##size(x, exponent)
Chunosovd621bca2017-11-03 17:33:15 +0700384#define ASYMM_MULT(a, b, size) asymm_mult##size(a, b)
Michele Di Giorgio14cbfb22019-10-23 10:53:10 +0100385#define ASYMM_MULT_BY_QUANT_MULTIPLIER_GREATER_THAN_ONE(x, quantized_multiplier, left_shift, size) \
386 ASYMM_MULT(x *((VEC_DATA_TYPE(int, size))(1) << (-left_shift)), quantized_multiplier, size)
Chunosovd621bca2017-11-03 17:33:15 +0700387#define ASYMM_MULT_BY_QUANT_MULTIPLIER_LESS_THAN_ONE(x, quantized_multiplier, right_shift, size) \
388 ASYMM_ROUNDING_DIVIDE_BY_POW2(ASYMM_MULT(x, quantized_multiplier, size), right_shift, size)
Giorgio Arenab99f00d2018-02-14 10:40:16 +0000389#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)
390#define ASYMM_SELECT_USING_MASK(if_mask, then_val, else_val, size) asymm_select_using_mask##size(if_mask, then_val, else_val)
391#define ASYMM_MASK_IF_ZERO(a, size) asymm_mask_if_zero##size(a)
392#define ASYMM_MASK_IF_NON_ZERO(a, size) asymm_mask_if_non_zero##size(a)
393#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)
394#define ASYMM_EXP_ON_NEGATIVE_VALUES(a, k_integer_bits, size) asymm_exp_on_negative_values##size(a, k_integer_bits)
395#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##size(a)
396#define ASYMM_SATURATING_ROUNDING_MULT_BY_POW2(x, exponent, size) asymm_saturating_rounding_mult_by_pow2##size(x, exponent)
397#define ASYMM_ROUNDING_HALF_SUM(a, b, size) asymm_rounding_half_sum##size(a, b)
398#define ASYMM_RESCALE(value, src_integer_bits, dst_integer_bits, size) asymm_rescale##size(value, src_integer_bits, dst_integer_bits)
Chunosovd621bca2017-11-03 17:33:15 +0700399
Manuel Bottini8481d832019-12-10 15:28:40 +0000400QUANTIZE_IMPL(uchar, 1)
401QUANTIZE_IMPL(char, 1)
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000402QUANTIZE_IMPL(uint, 1)
403QUANTIZE_IMPL(int, 1)
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100404QUANTIZE_IMPL(uchar, 4)
405QUANTIZE_IMPL(ushort, 4)
Michele Di Giorgio6b612f52019-09-05 12:30:22 +0100406QUANTIZE_IMPL(short, 4)
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000407QUANTIZE_IMPL(uchar, 16)
408QUANTIZE_IMPL(char, 16)
409QUANTIZE_IMPL(ushort, 16)
410QUANTIZE_IMPL(short, 16)
411QUANTIZE_IMPL(uint, 16)
412QUANTIZE_IMPL(int, 16)
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100413
Manuel Bottini8481d832019-12-10 15:28:40 +0000414DEQUANTIZE_IMPL(uchar, 1)
415DEQUANTIZE_IMPL(char, 1)
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000416DEQUANTIZE_IMPL(uint, 1)
417DEQUANTIZE_IMPL(int, 1)
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100418DEQUANTIZE_IMPL(uchar, 4)
419DEQUANTIZE_IMPL(ushort, 4)
Michele Di Giorgio6b612f52019-09-05 12:30:22 +0100420DEQUANTIZE_IMPL(short, 4)
Michalis Spyrou0b18d972020-01-30 18:11:13 +0000421DEQUANTIZE_IMPL(uchar, 16)
422DEQUANTIZE_IMPL(char, 16)
423DEQUANTIZE_IMPL(ushort, 16)
424DEQUANTIZE_IMPL(short, 16)
425DEQUANTIZE_IMPL(uint, 16)
426DEQUANTIZE_IMPL(int, 16)
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100427
Michele Di Giorgioa046e162019-10-08 09:36:26 +0100428ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(1)
Giorgio Arenab99f00d2018-02-14 10:40:16 +0000429ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(2)
430ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(4)
431ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(8)
432ASYMM_ROUNDING_DIVIDE_BY_POW2_IMPL(16)
433
Michele Di Giorgioa046e162019-10-08 09:36:26 +0100434ASYMM_MULT_IMPL(1)
Giorgio Arenab99f00d2018-02-14 10:40:16 +0000435ASYMM_MULT_IMPL(2)
436ASYMM_MULT_IMPL(4)
437ASYMM_MULT_IMPL(8)
438ASYMM_MULT_IMPL(16)
439
440ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(2)
441ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(4)
442ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(8)
443ASYMM_EXP_ON_INTERVAL_BETWEEN_NEGATIVE_ONE_QUARTER_AND_0_EXCL_IMPL(16)
444
445ASYMM_SELECT_USING_MASK_IMPL(2)
446ASYMM_SELECT_USING_MASK_IMPL(4)
447ASYMM_SELECT_USING_MASK_IMPL(8)
448ASYMM_SELECT_USING_MASK_IMPL(16)
449
450ASYMM_MASK_IF_ZERO_IMPL(2)
451ASYMM_MASK_IF_ZERO_IMPL(4)
452ASYMM_MASK_IF_ZERO_IMPL(8)
453ASYMM_MASK_IF_ZERO_IMPL(16)
454
455ASYMM_MASK_IF_NON_ZERO_IMPL(2)
456ASYMM_MASK_IF_NON_ZERO_IMPL(4)
457ASYMM_MASK_IF_NON_ZERO_IMPL(8)
458ASYMM_MASK_IF_NON_ZERO_IMPL(16)
459
460EXP_BARREL_SHIFTER_IMPL(2)
461EXP_BARREL_SHIFTER_IMPL(4)
462EXP_BARREL_SHIFTER_IMPL(8)
463EXP_BARREL_SHIFTER_IMPL(16)
464
465ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(2)
466ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(4)
467ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(8)
468ASYMM_EXP_ON_NEGATIVE_VALUES_IMPL(16)
469
470ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(2)
471ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(4)
472ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(8)
473ASYMM_SATURATING_ROUNDING_MULT_BY_POW2_IMPL(16)
474
475ASYMM_ROUNDING_HALF_SUM_IMPL(2)
476ASYMM_ROUNDING_HALF_SUM_IMPL(4)
477ASYMM_ROUNDING_HALF_SUM_IMPL(8)
478ASYMM_ROUNDING_HALF_SUM_IMPL(16)
479
480ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(2)
481ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(4)
482ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(8)
483ASYMM_ONE_OVER_ONE_PLUS_X_FOR_X_IN_0_1_IMPL(16)
484
485ASYMM_RESCALE_IMPL(2)
486ASYMM_RESCALE_IMPL(4)
487ASYMM_RESCALE_IMPL(8)
488ASYMM_RESCALE_IMPL(16)
489
Michele Di Giorgio4aff98f2019-08-28 16:27:26 +0100490#endif // ARM_COMPUTE_HELPERS_ASYMM_H