diff options
author | Michele Di Giorgio <michele.digiorgio@arm.com> | 2017-06-21 15:36:24 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:15:39 +0100 |
commit | ab0a77edcb9f48de2aad216323b791d0dd95a3cd (patch) | |
tree | dab2444a8f4ef70db08c7561b4b5f92648971a59 /src/core/CL/cl_kernels/fixed_point.h | |
parent | ccc65d44a53eaa61c718cbc4d826c811e2ccebda (diff) | |
download | ComputeLibrary-ab0a77edcb9f48de2aad216323b791d0dd95a3cd.tar.gz |
COMPMID-409: Add support for QS8 and QS16 CLPixelWiseMultiplication.
Change-Id: I7f66d49d746ba9fb6e726ccab83d3a97b8ddef80
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/78491
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Diffstat (limited to 'src/core/CL/cl_kernels/fixed_point.h')
-rw-r--r-- | src/core/CL/cl_kernels/fixed_point.h | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/core/CL/cl_kernels/fixed_point.h b/src/core/CL/cl_kernels/fixed_point.h index dcdf840444..b0dab0affc 100644 --- a/src/core/CL/cl_kernels/fixed_point.h +++ b/src/core/CL/cl_kernels/fixed_point.h @@ -162,13 +162,34 @@ SUBQ_SAT_IMPL(qs8x16) #define SUB_SAT_OP_EXPAND_STR(a, b, type, size) sub_sat_##type##x##size((a), (b)) #define SUB_SAT_OP_EXPAND(a, b, type, size) SUB_SAT_OP_EXPAND_STR(a, b, type, size) -/** Saturate multiply of two fixed point numbers - * - * @param[in] type the actual data type. - * @param[in] itype the intermediate data type. - * - * @return The result of the fixed point multiplication. The result is saturated in case of overflow - */ +/* Multiply of two fixed point numbers + * + * @param[in] type the actual data type. + * @param[in] itype the intermediate data type. + * + * @return The result of the fixed point multiplication. + */ +#define MULQ_IMPL(type, itype) \ + inline type mul_##type(type VopA, type VopB, int fixed_point_position) \ + { \ + itype round_val = (itype)(1 << (fixed_point_position - 1)); \ + itype res = CONVERT((VopA), itype) * CONVERT((VopB), itype) + round_val; \ + return CONVERT((res >> (itype)fixed_point_position), type); \ + } + +MULQ_IMPL(qs8x16, qs16x16) +MULQ_IMPL(qs16x16, qs32x16) + +#define MUL_OP_EXPAND_STR(a, b, type, size, position) mul_##type##x##size((a), (b), (position)) +#define MUL_OP_EXPAND(a, b, type, size, position) MUL_OP_EXPAND_STR(a, b, type, size, position) + +/* Saturate multiply of two fixed point numbers + * + * @param[in] type the actual data type. + * @param[in] itype the intermediate data type. + * + * @return The result of the fixed point multiplication. The result is saturated in case of overflow + */ #define MULQ_SAT_IMPL(type, itype) \ inline type mul_sat_##type(type VopA, type VopB, int fixed_point_position) \ { \ @@ -179,6 +200,7 @@ SUBQ_SAT_IMPL(qs8x16) MULQ_SAT_IMPL(qs8x16, qs16x16) MULQ_SAT_IMPL(qs16x8, qs32x8) +MULQ_SAT_IMPL(qs16x16, qs32x16) #define MUL_SAT_OP_EXPAND_STR(a, b, type, size, position) mul_sat_##type##x##size((a), (b), (position)) #define MUL_SAT_OP_EXPAND(a, b, type, size, position) MUL_SAT_OP_EXPAND_STR(a, b, type, size, position) |