51 const qint8_t round_val = 1 << (shift - 1);
58 const qint16_t round_val = 1 << (shift - 1);
139 const qint16_t round_up_const = (1 << (fixed_point_position - 1));
144 tmp += round_up_const;
146 return static_cast<qint8_t>(tmp >> fixed_point_position);
151 const qint32_t round_up_const = (1 << (fixed_point_position - 1));
156 tmp += round_up_const;
158 return static_cast<qint16_t>(tmp >> fixed_point_position);
163 const qint16_t round_up_const = (1 << (fixed_point_position - 1));
168 tmp += round_up_const;
175 const qint32_t round_up_const = (1 << (fixed_point_position - 1));
180 tmp += round_up_const;
187 const qint16_t round_up_const = (1 << (fixed_point_position - 1));
192 tmp += round_up_const;
194 return tmp >> fixed_point_position;
199 const qint32_t round_up_const = (1 << (fixed_point_position - 1));
204 tmp += round_up_const;
206 return tmp >> fixed_point_position;
211 const qint8_t shift = 8 - (fixed_point_position + (__builtin_clz(a) - 24));
213 const qint8_t const_three = (3 << fixed_point_position);
214 qint8_t temp = shift < 0 ? (a << -shift) : (a >> shift);
218 for(
int i = 0; i < 3; ++i)
221 x2 = (
smul_qs8(x2, three_minus_dx, fixed_point_position) >> 1);
224 temp = shift < 0 ? (x2 << (-shift >> 1)) : (x2 >> (shift >> 1));
231 const qint16_t shift = 16 - (fixed_point_position + (__builtin_clz(a) - 16));
233 const qint16_t const_three = (3 << fixed_point_position);
234 qint16_t temp = shift < 0 ? (a << -shift) : (a >> shift);
238 for(
int i = 0; i < 3; ++i)
241 x2 =
smul_qs16(x2, three_minus_dx, fixed_point_position) >> 1;
244 temp = shift < 0 ? (x2 << ((-shift) >> 1)) : (x2 >> (shift >> 1));
251 const qint16_t temp = a << fixed_point_position;
252 return static_cast<qint8_t>(temp /
b);
257 const qint32_t temp = a << fixed_point_position;
264 const qint8_t const_one = (1 << fixed_point_position);
265 const qint8_t ln2 = ((0x58 >> (6 - fixed_point_position)) + 1) >> 1;
266 const qint8_t inv_ln2 = (((0x38 >> (6 - fixed_point_position)) + 1) >> 1) | const_one;
267 const qint8_t A = ((0x7F >> (6 - fixed_point_position)) + 1) >> 1;
268 const qint8_t B = ((0x3F >> (6 - fixed_point_position)) + 1) >> 1;
269 const qint8_t C = ((0x16 >> (6 - fixed_point_position)) + 1) >> 1;
270 const qint8_t D = ((0x05 >> (6 - fixed_point_position)) + 1) >> 1;
273 const int dec_a = (
sqmul_qs8(a, inv_ln2, fixed_point_position) >> fixed_point_position);
278 sum =
sqmul_qs8(alpha, sum, fixed_point_position);
281 return (dec_a < 0) ? (sum >> -dec_a) :
sqshl_qs8(sum, dec_a);
287 const qint16_t const_one = (1 << fixed_point_position);
288 const qint16_t ln2 = ((0x58B9 >> (14 - fixed_point_position)) + 1) >> 1;
289 const qint16_t inv_ln2 = (((0x38AA >> (14 - fixed_point_position)) + 1) >> 1) | const_one;
290 const qint16_t A = ((0x7FBA >> (14 - fixed_point_position)) + 1) >> 1;
291 const qint16_t B = ((0x3FE9 >> (14 - fixed_point_position)) + 1) >> 1;
292 const qint16_t C = ((0x1693 >> (14 - fixed_point_position)) + 1) >> 1;
293 const qint16_t D = ((0x0592 >> (14 - fixed_point_position)) + 1) >> 1;
296 const int dec_a = (
sqmul_qs16(a, inv_ln2, fixed_point_position) >> fixed_point_position);
301 sum =
sqmul_qs16(alpha, sum, fixed_point_position);
304 return (dec_a < 0) ? (sum >> -dec_a) :
sqshl_qs16(sum, dec_a);
310 qint8_t const_one = (1 << fixed_point_position);
311 qint8_t ln2 = (0x58 >> (7 - fixed_point_position));
312 qint8_t A = (0x5C >> (7 - fixed_point_position - 1));
313 qint8_t B = -(0x56 >> (7 - fixed_point_position));
314 qint8_t C = (0x29 >> (7 - fixed_point_position));
315 qint8_t D = -(0x0A >> (7 - fixed_point_position));
317 if((const_one == a) || (a < 0))
321 else if(a < const_one)
323 return -
slog_qs8(
sdiv_qs8(const_one, a, fixed_point_position), fixed_point_position);
327 qint8_t shift_val = 31 - __builtin_clz(a >> fixed_point_position);
335 sum =
sqmul_qs8(a, sum, fixed_point_position);
337 return smul_qs8(
sadd_qs8(sum, shift_val << fixed_point_position), ln2, fixed_point_position);
343 qint16_t const_one = (1 << fixed_point_position);
344 qint16_t ln2 = (0x58B9 >> (7 - fixed_point_position));
345 qint16_t A = (0x5C0F >> (7 - fixed_point_position - 1));
346 qint16_t B = -(0x56AE >> (7 - fixed_point_position));
347 qint16_t C = (0x2933 >> (7 - fixed_point_position));
348 qint16_t D = -(0x0AA7 >> (7 - fixed_point_position));
350 if((const_one == a) || (a < 0))
354 else if(a < const_one)
356 return -
slog_qs16(
sdiv_qs16(const_one, a, fixed_point_position), fixed_point_position);
360 qint16_t shift_val = 31 - __builtin_clz(a >> fixed_point_position);
368 sum =
sqmul_qs16(a, sum, fixed_point_position);
370 return smul_qs16(
sadd_qs16(sum, shift_val << fixed_point_position), ln2, fixed_point_position);
375 return static_cast<float>(
a) / (1 << fixed_point_position);
386 return static_cast<float>(
a) / (1 << fixed_point_position);
fixed_point< T > min(fixed_point< T > x, fixed_point< T > y)
int64_t qint64_t
64 bit fixed point scalar value
qint16_t sabs_qs16(qint16_t a)
16 bit fixed point scalar absolute value
qint8_t smul_qs8(qint8_t a, qint8_t b, int fixed_point_position)
8 bit fixed point scalar multiply
qint8_t ssub_qs8(qint8_t a, qint8_t b)
8 bit fixed point scalar subtraction
float scvt_f32_qs16(qint16_t a, int fixed_point_position)
Convert a 16 bit fixed point to float.
qint16_t sdiv_qs16(qint16_t a, qint16_t b, int fixed_point_position)
16 bit fixed point scalar division
float scvt_f32_qs8(qint8_t a, int fixed_point_position)
Convert an 8 bit fixed point to float.
DATA_TYPE sum(__global const DATA_TYPE *input)
Calculate sum of a vector.
qint16_t sqexp_qs16(qint16_t a, int fixed_point_position)
16 bit fixed point scalar exponential
T saturate_cast(U val)
Type cast with saturation.
qint32_t sqadd_qs32(qint32_t a, qint32_t b)
32 bit fixed point scalar saturating add
qint16_t sqshl_qs16(qint16_t a, int shift)
16 bit fixed point scalar saturating shift left
This file contains all available output stages for GEMMLowp on OpenCL.
qint16_t sqmovn_qs32(qint32_t a)
Scalar saturating move and narrow.
qint16_t slog_qs16(qint16_t a, int fixed_point_position)
16 bit fixed point scalar logarithm
qint32_t sqmull_qs16(qint16_t a, qint16_t b, int fixed_point_position)
16 bit fixed point scalar multiply long
qint8_t sadd_qs8(qint8_t a, qint8_t b)
8 bit fixed point scalar add
qint8_t sdiv_qs8(qint8_t a, qint8_t b, int fixed_point_position)
8 bit fixed point scalar division
qint16_t smul_qs16(qint16_t a, qint16_t b, int fixed_point_position)
16 bit fixed point scalar multiply
qint8_t sqshl_qs8(qint8_t a, int shift)
8 bit fixed point scalar saturating shift left
int32_t qint32_t
32 bit fixed point scalar value
int16_t qint16_t
16 bit fixed point scalar value
qint16_t sqcvt_qs16_f32(float a, int fixed_point_position)
Convert a float to 16 bit fixed point.
qint16_t sqadd_qs16(qint16_t a, qint16_t b)
16 bit fixed point scalar saturating add
qint8_t sqsub_qs8(qint8_t a, qint8_t b)
8 bit fixed point scalar saturating subtraction
qint16_t sinvsqrt_qs16(qint16_t a, int fixed_point_position)
16 bit fixed point scalar inverse square root
qint16_t sqmull_qs8(qint8_t a, qint8_t b, int fixed_point_position)
8 bit fixed point scalar multiply long
qint8_t sqmovn_qs16(qint16_t a)
Scalar saturating move and narrow.
qint8_t sqmul_qs8(qint8_t a, qint8_t b, int fixed_point_position)
8 bit fixed point scalar saturating multiply
qint8_t slog_qs8(qint8_t a, int fixed_point_position)
8 bit fixed point scalar logarithm
qint8_t sqexp_qs8(qint8_t a, int fixed_point_position)
8 bit fixed point scalar exponential
int8_t qint8_t
8 bit fixed point scalar value
qint16_t ssub_qs16(qint16_t a, qint16_t b)
16 bit fixed point scalar subtraction
qint8_t sshr_qs8(qint8_t a, int shift)
8 bit fixed point scalar shift right
qint16_t sshr_qs16(qint16_t a, int shift)
16 bit fixed point scalar shift right
qint8_t sinvsqrt_qs8(qint8_t a, int fixed_point_position)
8 bit fixed point scalar inverse square root
qint16_t sqsub_qs16(qint16_t a, qint16_t b)
16 bit fixed point scalar saturating subtraction
fixed_point< T > max(fixed_point< T > x, fixed_point< T > y)
qint8_t sabs_qs8(qint8_t a)
8 bit fixed point scalar absolute value
qint16_t sadd_qs16(qint16_t a, qint16_t b)
16 bit fixed point scalar add
qint8_t sqcvt_qs8_f32(float a, int fixed_point_position)
Convert a float to 8 bit fixed point.
qint8_t sqadd_qs8(qint8_t a, qint8_t b)
8 bit fixed point scalar saturating add
#define ARM_COMPUTE_ERROR_ON_MSG(cond,...)
qint16_t sqmul_qs16(qint16_t a, qint16_t b, int fixed_point_position)
16 bit fixed point scalar saturating multiply