Line data Source code
1 1 : /* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. 2 : * SPDX-License-Identifier: Apache-2.0 3 : */ 4 : 5 : /** 6 : * @file zephyr/dsp/basicmath_f16.h 7 : * 8 : * @brief Public APIs for DSP basicmath for 16 bit floating point 9 : */ 10 : 11 : #ifndef ZEPHYR_INCLUDE_DSP_BASICMATH_F16_H_ 12 : #define ZEPHYR_INCLUDE_DSP_BASICMATH_F16_H_ 13 : 14 : #ifndef CONFIG_FP16 15 : #error "Cannot use float16 DSP functionality without CONFIG_FP16 enabled" 16 : #endif /* CONFIG_FP16 */ 17 : 18 : #include <zephyr/dsp/dsp.h> 19 : 20 : #ifdef __cplusplus 21 : extern "C" { 22 : #endif 23 : 24 : /** 25 : * @ingroup math_dsp_basic_mult 26 : * @brief Floating-point vector multiplication. 27 : * @param[in] src_a points to the first input vector 28 : * @param[in] src_b points to the second input vector 29 : * @param[out] dst points to the output vector 30 : * @param[in] block_size number of samples in each vector 31 : */ 32 1 : DSP_FUNC_SCOPE void zdsp_mult_f16(const float16_t *src_a, const float16_t *src_b, float16_t *dst, 33 : uint32_t block_size); 34 : 35 : /** 36 : * @ingroup math_dsp_basic_add 37 : * @brief Floating-point vector addition. 38 : * @param[in] src_a points to the first input vector 39 : * @param[in] src_b points to the second input vector 40 : * @param[out] dst points to the output vector 41 : * @param[in] block_size number of samples in each vector 42 : */ 43 1 : DSP_FUNC_SCOPE void zdsp_add_f16(const float16_t *src_a, const float16_t *src_b, float16_t *dst, 44 : uint32_t block_size); 45 : 46 : /** 47 : * @ingroup math_dsp_basic_sub 48 : * @brief Floating-point vector subtraction. 49 : * @param[in] src_a points to the first input vector 50 : * @param[in] src_b points to the second input vector 51 : * @param[out] dst points to the output vector 52 : * @param[in] block_size number of samples in each vector 53 : */ 54 1 : DSP_FUNC_SCOPE void zdsp_sub_f16(const float16_t *src_a, const float16_t *src_b, float16_t *dst, 55 : uint32_t block_size); 56 : 57 : /** 58 : * @ingroup math_dsp_basic_scale 59 : * @brief Multiplies a floating-point vector by a scalar. 60 : * @param[in] src points to the input vector 61 : * @param[in] scale scale factor to be applied 62 : * @param[out] dst points to the output vector 63 : * @param[in] block_size number of samples in the vector 64 : */ 65 1 : DSP_FUNC_SCOPE void zdsp_scale_f16(const float16_t *src, float16_t scale, float16_t *dst, 66 : uint32_t block_size); 67 : 68 : /** 69 : * @ingroup math_dsp_basic_abs 70 : * @brief Floating-point vector absolute value. 71 : * @param[in] src points to the input buffer 72 : * @param[out] dst points to the output buffer 73 : * @param[in] block_size number of samples in each vector 74 : */ 75 1 : DSP_FUNC_SCOPE void zdsp_abs_f16(const float16_t *src, float16_t *dst, uint32_t block_size); 76 : 77 : /** 78 : * @ingroup math_dsp_basic_dot 79 : * @brief Dot product of floating-point vectors. 80 : * @param[in] src_a points to the first input vector 81 : * @param[in] src_b points to the second input vector 82 : * @param[in] block_size number of samples in each vector 83 : * @param[out] result output result returned here 84 : */ 85 1 : DSP_FUNC_SCOPE void zdsp_dot_prod_f16(const float16_t *src_a, const float16_t *src_b, 86 : uint32_t block_size, float16_t *result); 87 : 88 : /** 89 : * @ingroup math_dsp_basic_offset 90 : * @brief Adds a constant offset to a floating-point vector. 91 : * @param[in] src points to the input vector 92 : * @param[in] offset is the offset to be added 93 : * @param[out] dst points to the output vector 94 : * @param[in] block_size number of samples in the vector 95 : */ 96 1 : DSP_FUNC_SCOPE void zdsp_offset_f16(const float16_t *src, float16_t offset, float16_t *dst, 97 : uint32_t block_size); 98 : 99 : /** 100 : * @ingroup math_dsp_basic_negate 101 : * @brief Negates the elements of a floating-point vector. 102 : * @param[in] src points to the input vector 103 : * @param[out] dst points to the output vector 104 : * @param[in] block_size number of samples in the vector 105 : */ 106 1 : DSP_FUNC_SCOPE void zdsp_negate_f16(const float16_t *src, float16_t *dst, uint32_t block_size); 107 : 108 : /** 109 : * @ingroup math_dsp_basic_clip 110 : * @brief Elementwise floating-point clipping 111 : * @param[in] src points to input values 112 : * @param[out] dst points to output clipped values 113 : * @param[in] low lower bound 114 : * @param[in] high higher bound 115 : * @param[in] num_samples number of samples to clip 116 : */ 117 1 : DSP_FUNC_SCOPE void zdsp_clip_f16(const float16_t *src, float16_t *dst, float16_t low, 118 : float16_t high, uint32_t num_samples); 119 : 120 : #ifdef __cplusplus 121 : } 122 : #endif 123 : 124 : #endif /* ZEPHYR_INCLUDE_DSP_BASICMATH_F16_H_ */