1 /* Copyright (c) 2022 Google LLC
2 * SPDX-License-Identifier: Apache-2.0
3 */
4
5 #ifndef SUBSYS_DSP_CMSIS_PUBLIC_ZDSP_BACKEND_F16_H_
6 #define SUBSYS_DSP_CMSIS_PUBLIC_ZDSP_BACKEND_F16_H_
7
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11
12 /* This include MUST be done before arm_math.h so we can let the arch specific
13 * logic set up the right #define values for arm_math.h
14 */
15 #include <zephyr/kernel.h>
16
17 #include <arm_math_f16.h>
18
zdsp_mult_f16(const float16_t * src_a,const float16_t * src_b,float16_t * dst,uint32_t block_size)19 static inline void zdsp_mult_f16(const float16_t *src_a, const float16_t *src_b, float16_t *dst,
20 uint32_t block_size)
21 {
22 arm_mult_f16(src_a, src_b, dst, block_size);
23 }
24
zdsp_add_f16(const float16_t * src_a,const float16_t * src_b,float16_t * dst,uint32_t block_size)25 static inline void zdsp_add_f16(const float16_t *src_a, const float16_t *src_b, float16_t *dst,
26 uint32_t block_size)
27 {
28 arm_add_f16(src_a, src_b, dst, block_size);
29 }
30
zdsp_sub_f16(const float16_t * src_a,const float16_t * src_b,float16_t * dst,uint32_t block_size)31 static inline void zdsp_sub_f16(const float16_t *src_a, const float16_t *src_b, float16_t *dst,
32 uint32_t block_size)
33 {
34 arm_sub_f16(src_a, src_b, dst, block_size);
35 }
36
zdsp_scale_f16(const float16_t * src,float16_t scale,float16_t * dst,uint32_t block_size)37 static inline void zdsp_scale_f16(const float16_t *src, float16_t scale, float16_t *dst,
38 uint32_t block_size)
39 {
40 arm_scale_f16(src, scale, dst, block_size);
41 }
42
zdsp_abs_f16(const float16_t * src,float16_t * dst,uint32_t block_size)43 static inline void zdsp_abs_f16(const float16_t *src, float16_t *dst, uint32_t block_size)
44 {
45 arm_abs_f16(src, dst, block_size);
46 }
47
zdsp_dot_prod_f16(const float16_t * src_a,const float16_t * src_b,uint32_t block_size,float16_t * result)48 static inline void zdsp_dot_prod_f16(const float16_t *src_a, const float16_t *src_b,
49 uint32_t block_size, float16_t *result)
50 {
51 arm_dot_prod_f16(src_a, src_b, block_size, result);
52 }
53
zdsp_offset_f16(const float16_t * src,float16_t offset,float16_t * dst,uint32_t block_size)54 static inline void zdsp_offset_f16(const float16_t *src, float16_t offset, float16_t *dst,
55 uint32_t block_size)
56 {
57 arm_offset_f16(src, offset, dst, block_size);
58 }
59
zdsp_negate_f16(const float16_t * src,float16_t * dst,uint32_t block_size)60 static inline void zdsp_negate_f16(const float16_t *src, float16_t *dst, uint32_t block_size)
61 {
62 arm_negate_f16(src, dst, block_size);
63 }
64
zdsp_clip_f16(const float16_t * src,float16_t * dst,float16_t low,float16_t high,uint32_t num_samples)65 static inline void zdsp_clip_f16(const float16_t *src, float16_t *dst, float16_t low,
66 float16_t high, uint32_t num_samples)
67 {
68 arm_clip_f16(src, dst, low, high, num_samples);
69 }
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif /* SUBSYS_DSP_CMSIS_PUBLIC_ZDSP_BACKEND_F16_H_ */
76