aboutsummaryrefslogtreecommitdiff
path: root/src/core/CL/cl_kernels/fixed_point.h
diff options
context:
space:
mode:
authorsteniu01 <steven.niu@arm.com>2017-06-29 10:14:58 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:15:39 +0100
commitda37e2fa661f85090bd4a3b93c07178df268bd8c (patch)
tree18c1937779c28e277ec6a0d9424ddc90f2292c87 /src/core/CL/cl_kernels/fixed_point.h
parent34702479adcf3559e8ebe27915179af509b070d2 (diff)
downloadComputeLibrary-da37e2fa661f85090bd4a3b93c07178df268bd8c.tar.gz
COMPMID-431 Port CLDepthConvert to use 8-bit and 16-bit fixed point
Change-Id: Iedea9e985427e6242f34a5362615f79c0526d5bd Reviewed-on: http://mpd-gerrit.cambridge.arm.com/79786 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.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/core/CL/cl_kernels/fixed_point.h b/src/core/CL/cl_kernels/fixed_point.h
index 9fd3a6f899..5d340c4e95 100644
--- a/src/core/CL/cl_kernels/fixed_point.h
+++ b/src/core/CL/cl_kernels/fixed_point.h
@@ -381,4 +381,34 @@ INVSQRTQ_IMPL(qs8, qs8x16, 16)
#define INVSQRT_OP_EXPAND_STR(a, type, size, position) invsqrt_sat_##type##x##size((a), (position))
#define INVSQRT_OP_EXPAND(a, type, size, position) INVSQRT_OP_EXPAND_STR(a, type, size, position)
+#define floatx16 float16
+#define float16_TYPE float16
+
+#define CONVERTQ_DOWN_IMPL(in_type, out_type) \
+ inline out_type convert_##out_type##_##in_type(in_type a, int fixed_point_position) \
+ { \
+ return CONVERT(a * (1 << fixed_point_position) + select((in_type)-0.5, (in_type)0.5, isgreater(a, (in_type)0)), out_type); \
+ }
+
+CONVERTQ_DOWN_IMPL(float16, qs8x16)
+CONVERTQ_DOWN_IMPL(float16, qs16x16)
+
+#define CONVERTQ_DOWN_SAT_IMPL(in_type, out_type) \
+ inline out_type convert_##out_type##_##in_type##_sat(in_type a, int fixed_point_position) \
+ { \
+ return CONVERT_SAT(a * (1 << fixed_point_position) + select((in_type)-0.5, (in_type)0.5, isgreater(a, (in_type)0)), out_type); \
+ }
+
+CONVERTQ_DOWN_SAT_IMPL(float16, qs8x16)
+CONVERTQ_DOWN_SAT_IMPL(float16, qs16x16)
+
+#define CONVERTQ_UP_IMPL(in_type, out_type) \
+ inline out_type convert_##out_type##_##in_type(in_type a, int fixed_point_position) \
+ { \
+ return CONVERT(a, out_type) / (1 << fixed_point_position); \
+ }
+
+CONVERTQ_UP_IMPL(qs8x16, float16)
+CONVERTQ_UP_IMPL(qs16x16, float16)
+
#endif // ARM_COMPUTE_FIXED_POINT_H