diff options
author | Michalis Spyrou <michalis.spyrou@arm.com> | 2017-06-14 18:00:05 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:15:39 +0100 |
commit | 0a8334cb78dae66fdc31257a96ba15f7c41bde50 (patch) | |
tree | c8e5f290f8a9a674588e1d67f6a623debf9397f7 /arm_compute/core/FixedPoint.h | |
parent | e5f8fd64a46ce61dac61fd50095a27cfd94930b5 (diff) | |
download | ComputeLibrary-0a8334cb78dae66fdc31257a96ba15f7c41bde50.tar.gz |
COMPMID-400 Add support for 16 bit fixed point arithmetic.
Change-Id: Iebfaef1b219d80d6362b7fd4b1357612b31e43cb
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/77749
Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'arm_compute/core/FixedPoint.h')
-rw-r--r-- | arm_compute/core/FixedPoint.h | 115 |
1 files changed, 113 insertions, 2 deletions
diff --git a/arm_compute/core/FixedPoint.h b/arm_compute/core/FixedPoint.h index 925b4949a3..da304c6329 100644 --- a/arm_compute/core/FixedPoint.h +++ b/arm_compute/core/FixedPoint.h @@ -33,12 +33,21 @@ using qint32_t = int32_t; /**< 32 bit fixed point scalar value */ /** 8 bit fixed point scalar saturating shift left * * @param[in] a First 8 bit fixed point input - * @param[in] shift Shift amount + * @param[in] shift Shift amount (positive only values) * * @return The result of the 8 bit fixed point shift. The result is saturated in case of overflow */ qint8_t sqshl_qs8(qint8_t a, int shift); +/** 16 bit fixed point scalar saturating shift left + * + * @param[in] a First 16 bit fixed point input + * @param[in] shift Shift amount (positive only values) + * + * @return The result of the 16 bit fixed point shift. The result is saturated in case of overflow + */ +qint16_t sqshl_qs16(qint16_t a, int shift); + /** 8 bit fixed point scalar absolute value * * @param[in] a 8 bit fixed point input @@ -47,6 +56,14 @@ qint8_t sqshl_qs8(qint8_t a, int shift); */ qint8_t sabs_qs8(qint8_t a); +/** 16 bit fixed point scalar absolute value + * + * @param[in] a 16 bit fixed point input + * + * @return The result of the 16 bit fixed point absolute value + */ +qint16_t sabs_qs16(qint16_t a); + /** 8 bit fixed point scalar add * * @param[in] a First 8 bit fixed point input @@ -56,6 +73,15 @@ qint8_t sabs_qs8(qint8_t a); */ qint8_t sadd_qs8(qint8_t a, qint8_t b); +/** 16 bit fixed point scalar add + * + * @param[in] a First 16 bit fixed point input + * @param[in] b Second 16 bit fixed point input + * + * @return The result of the 16 bit fixed point addition + */ +qint16_t sadd_qs16(qint16_t a, qint16_t b); + /** 8 bit fixed point scalar saturating add * * @param[in] a First 8 bit fixed point input @@ -83,6 +109,15 @@ qint16_t sqadd_qs16(qint16_t a, qint16_t b); */ qint8_t ssub_qs8(qint8_t a, qint8_t b); +/** 16 bit fixed point scalar subtraction + * + * @param[in] a First 16 bit fixed point input + * @param[in] b Second 16 bit fixed point input + * + * @return The result of the 16 bit fixed point subtraction + */ +qint16_t ssub_qs16(qint16_t a, qint16_t b); + /** 8 bit fixed point scalar saturating subtraction * * @param[in] a First 8 bit fixed point input @@ -92,6 +127,15 @@ qint8_t ssub_qs8(qint8_t a, qint8_t b); */ qint8_t sqsub_qs8(qint8_t a, qint8_t b); +/** 16 bit fixed point scalar saturating subtraction + * + * @param[in] a First 16 bit fixed point input + * @param[in] b Second 16 bit fixed point input + * + * @return The result of the 16 bit fixed point subtraction. The result is saturated in case of overflow + */ +qint16_t sqsub_qs16(qint16_t a, qint16_t b); + /** 8 bit fixed point scalar multiply * * @param[in] a First 8 bit fixed point input @@ -102,6 +146,16 @@ qint8_t sqsub_qs8(qint8_t a, qint8_t b); */ qint8_t smul_qs8(qint8_t a, qint8_t b, int fixed_point_position); +/** 16 bit fixed point scalar multiply + * + * @param[in] a First 16 bit fixed point input + * @param[in] b Second 16 bit fixed point input + * @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number + * + * @return The result of the 16 bit fixed point multiplication. + */ +qint16_t smul_qs16(qint16_t a, qint16_t b, int fixed_point_position); + /** 8 bit fixed point scalar saturating multiply * * @param[in] a First 8 bit fixed point input @@ -112,6 +166,16 @@ qint8_t smul_qs8(qint8_t a, qint8_t b, int fixed_point_position); */ qint8_t sqmul_qs8(qint8_t a, qint8_t b, int fixed_point_position); +/** 16 bit fixed point scalar saturating multiply + * + * @param[in] a First 16 bit fixed point input + * @param[in] b Second 16 bit fixed point input + * @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number + * + * @return The result of the 16 bit fixed point multiplication. The result is saturated in case of overflow + */ +qint16_t sqmul_qs16(qint16_t a, qint16_t b, int fixed_point_position); + /** 8 bit fixed point scalar multiply long * * @param[in] a First 8 bit fixed point input @@ -122,6 +186,16 @@ qint8_t sqmul_qs8(qint8_t a, qint8_t b, int fixed_point_position); */ qint16_t sqmull_qs8(qint8_t a, qint8_t b, int fixed_point_position); +/** 16 bit fixed point scalar multiply long + * + * @param[in] a First 16 bit fixed point input + * @param[in] b Second 16 bit fixed point input + * @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number + * + * @return The result of the 16 bit fixed point multiplication long. The result is saturated in case of overflow + */ +qint32_t sqmull_qs16(qint16_t a, qint16_t b, int fixed_point_position); + /** 16 bit fixed point scalar saturating multiply * * @param[in] a First 16 bit fixed point input @@ -141,6 +215,15 @@ qint16_t sqmul_qs16(qint16_t a, qint16_t b, int fixed_point_position); */ qint8_t sinvsqrt_qs8(qint8_t a, int fixed_point_position); +/** 16 bit fixed point scalar inverse square root +* +* @param[in] a 16 bit fixed point input +* @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number +* +* @return The result of the 16 bit fixed point inverse square root. +*/ +qint16_t sinvsqrt_qs16(qint16_t a, int fixed_point_position); + /** 8 bit fixed point scalar division * * @param[in] a First 8 bit fixed point input @@ -151,6 +234,16 @@ qint8_t sinvsqrt_qs8(qint8_t a, int fixed_point_position); */ qint8_t sdiv_qs8(qint8_t a, qint8_t b, int fixed_point_position); +/** 16 bit fixed point scalar division +* +* @param[in] a First 16 bit fixed point input +* @param[in] b Second 16 bit fixed point input +* @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number +* +* @return The result of the 16 bit fixed point division. +*/ +qint16_t sdiv_qs16(qint16_t a, qint16_t b, int fixed_point_position); + /** 8 bit fixed point scalar exponential * * @param[in] a 8 bit fixed point input @@ -160,6 +253,15 @@ qint8_t sdiv_qs8(qint8_t a, qint8_t b, int fixed_point_position); */ qint8_t sexp_qs8(qint8_t a, int fixed_point_position); +/** 16 bit fixed point scalar exponential +* +* @param[in] a 16 bit fixed point input +* @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number +* +* @return The result of the 16 bit fixed point exponential. +*/ +qint16_t sexp_qs16(qint16_t a, int fixed_point_position); + /** 8 bit fixed point scalar logarithm * * @param[in] a 8 bit fixed point input @@ -169,6 +271,15 @@ qint8_t sexp_qs8(qint8_t a, int fixed_point_position); */ qint8_t slog_qs8(qint8_t a, int fixed_point_position); +/** 16 bit fixed point scalar logarithm +* +* @param[in] a 16 bit fixed point input +* @param[in] fixed_point_position Fixed point position that expresses the number of bits for the fractional part of the number +* +* @return The result of the 16 bit fixed point logarithm. +*/ +qint16_t slog_qs16(qint16_t a, int fixed_point_position); + /** Convert an 8 bit fixed point to float * * @param[in] a Input to convert @@ -203,7 +314,7 @@ float scvt_f32_qs16(qint16_t a, int fixed_point_position); * * @return The result of the conversion float -> 16 bit fixed point */ -qint8_t scvt_qs16_f32(float a, int fixed_point_position); +qint16_t scvt_qs16_f32(float a, int fixed_point_position); /** Scalar saturating move and narrow. * |