55 * SPDX-License-Identifier: Apache-2.0
66 */
77
8+ #include <zephyr/dsp/dsp.h>
89#include <zephyr/ztest.h>
910#include <zephyr/kernel.h>
1011#include <stdlib.h>
11- #include <arm_math_f16.h>
1212#include "common/test_common.h"
1313
1414#include "f16.pat"
1717#define SNR_DOTPROD_THRESH ((float32_t)40)
1818#define REL_ERROR_THRESH (4.0e-2)
1919
20- static void test_arm_add_f16 (
20+ static void test_zdsp_add_f16 (
2121 const uint16_t * input1 , const uint16_t * input2 , const uint16_t * ref ,
2222 size_t length )
2323{
@@ -28,7 +28,7 @@ static void test_arm_add_f16(
2828 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
2929
3030 /* Run test function */
31- arm_add_f16 ((float16_t * )input1 , (float16_t * )input2 , output , length );
31+ zdsp_add_f16 ((float16_t * )input1 , (float16_t * )input2 , output , length );
3232
3333 /* Validate output */
3434 zassert_true (
@@ -45,13 +45,13 @@ static void test_arm_add_f16(
4545 free (output );
4646}
4747
48- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_add_f16 , 7 , in_com1 , in_com2 , ref_add , 7 );
49- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_add_f16 , 16 , in_com1 , in_com2 , ref_add , 16 );
50- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_add_f16 , 23 , in_com1 , in_com2 , ref_add , 23 );
51- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_add_f16 , long , in_com1 , in_com2 , ref_add ,
48+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_add_f16 , 7 , in_com1 , in_com2 , ref_add , 7 );
49+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_add_f16 , 16 , in_com1 , in_com2 , ref_add , 16 );
50+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_add_f16 , 23 , in_com1 , in_com2 , ref_add , 23 );
51+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_add_f16 , long , in_com1 , in_com2 , ref_add ,
5252 ARRAY_SIZE (in_com1 ));
5353
54- static void test_arm_sub_f16 (
54+ static void test_zdsp_sub_f16 (
5555 const uint16_t * input1 , const uint16_t * input2 , const uint16_t * ref ,
5656 size_t length )
5757{
@@ -62,7 +62,7 @@ static void test_arm_sub_f16(
6262 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
6363
6464 /* Run test function */
65- arm_sub_f16 ((float16_t * )input1 , (float16_t * )input2 , output , length );
65+ zdsp_sub_f16 ((float16_t * )input1 , (float16_t * )input2 , output , length );
6666
6767 /* Validate output */
6868 zassert_true (
@@ -79,13 +79,13 @@ static void test_arm_sub_f16(
7979 free (output );
8080}
8181
82- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_sub_f16 , 7 , in_com1 , in_com2 , ref_sub , 7 );
83- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_sub_f16 , 16 , in_com1 , in_com2 , ref_sub , 16 );
84- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_sub_f16 , 23 , in_com1 , in_com2 , ref_sub , 23 );
85- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_sub_f16 , long , in_com1 , in_com2 , ref_sub ,
82+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_sub_f16 , 7 , in_com1 , in_com2 , ref_sub , 7 );
83+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_sub_f16 , 16 , in_com1 , in_com2 , ref_sub , 16 );
84+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_sub_f16 , 23 , in_com1 , in_com2 , ref_sub , 23 );
85+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_sub_f16 , long , in_com1 , in_com2 , ref_sub ,
8686 ARRAY_SIZE (in_com1 ));
8787
88- static void test_arm_mult_f16 (
88+ static void test_zdsp_mult_f16 (
8989 const uint16_t * input1 , const uint16_t * input2 , const uint16_t * ref ,
9090 size_t length )
9191{
@@ -96,7 +96,7 @@ static void test_arm_mult_f16(
9696 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
9797
9898 /* Run test function */
99- arm_mult_f16 ((float16_t * )input1 , (float16_t * )input2 , output , length );
99+ zdsp_mult_f16 ((float16_t * )input1 , (float16_t * )input2 , output , length );
100100
101101 /* Validate output */
102102 zassert_true (
@@ -113,13 +113,13 @@ static void test_arm_mult_f16(
113113 free (output );
114114}
115115
116- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_mult_f16 , 7 , in_com1 , in_com2 , ref_mult , 7 );
117- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_mult_f16 , 16 , in_com1 , in_com2 , ref_mult , 16 );
118- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_mult_f16 , 23 , in_com1 , in_com2 , ref_mult , 23 );
119- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_mult_f16 , long , in_com1 , in_com2 , ref_mult ,
116+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_mult_f16 , 7 , in_com1 , in_com2 , ref_mult , 7 );
117+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_mult_f16 , 16 , in_com1 , in_com2 , ref_mult , 16 );
118+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_mult_f16 , 23 , in_com1 , in_com2 , ref_mult , 23 );
119+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_mult_f16 , long , in_com1 , in_com2 , ref_mult ,
120120 ARRAY_SIZE (in_com1 ));
121121
122- static void test_arm_negate_f16 (
122+ static void test_zdsp_negate_f16 (
123123 const uint16_t * input1 , const uint16_t * ref , size_t length )
124124{
125125 float16_t * output ;
@@ -129,7 +129,7 @@ static void test_arm_negate_f16(
129129 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
130130
131131 /* Run test function */
132- arm_negate_f16 ((float16_t * )input1 , output , length );
132+ zdsp_negate_f16 ((float16_t * )input1 , output , length );
133133
134134 /* Validate output */
135135 zassert_true (
@@ -146,13 +146,13 @@ static void test_arm_negate_f16(
146146 free (output );
147147}
148148
149- DEFINE_TEST_VARIANT3 (basic_math_f16 , arm_negate_f16 , 7 , in_com1 , ref_negate , 7 );
150- DEFINE_TEST_VARIANT3 (basic_math_f16 , arm_negate_f16 , 16 , in_com1 , ref_negate , 16 );
151- DEFINE_TEST_VARIANT3 (basic_math_f16 , arm_negate_f16 , 23 , in_com1 , ref_negate , 23 );
152- DEFINE_TEST_VARIANT3 (basic_math_f16 , arm_negate_f16 , long , in_com1 , ref_negate ,
149+ DEFINE_TEST_VARIANT3 (basic_math_f16 , zdsp_negate_f16 , 7 , in_com1 , ref_negate , 7 );
150+ DEFINE_TEST_VARIANT3 (basic_math_f16 , zdsp_negate_f16 , 16 , in_com1 , ref_negate , 16 );
151+ DEFINE_TEST_VARIANT3 (basic_math_f16 , zdsp_negate_f16 , 23 , in_com1 , ref_negate , 23 );
152+ DEFINE_TEST_VARIANT3 (basic_math_f16 , zdsp_negate_f16 , long , in_com1 , ref_negate ,
153153 ARRAY_SIZE (in_com1 ));
154154
155- static void test_arm_offset_f16 (
155+ static void test_zdsp_offset_f16 (
156156 const uint16_t * input1 , float16_t scalar , const uint16_t * ref ,
157157 size_t length )
158158{
@@ -163,7 +163,7 @@ static void test_arm_offset_f16(
163163 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
164164
165165 /* Run test function */
166- arm_offset_f16 ((float16_t * )input1 , scalar , output , length );
166+ zdsp_offset_f16 ((float16_t * )input1 , scalar , output , length );
167167
168168 /* Validate output */
169169 zassert_true (
@@ -180,13 +180,13 @@ static void test_arm_offset_f16(
180180 free (output );
181181}
182182
183- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_offset_f16 , 0p5 _7 , in_com1 , 0.5f , ref_offset , 7 );
184- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_offset_f16 , 0p5 _16 , in_com1 , 0.5f , ref_offset , 16 );
185- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_offset_f16 , 0p5 _23 , in_com1 , 0.5f , ref_offset , 23 );
186- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_offset_f16 , long , in_com1 , 0.5f , ref_offset ,
183+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_offset_f16 , 0p5 _7 , in_com1 , 0.5f , ref_offset , 7 );
184+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_offset_f16 , 0p5 _16 , in_com1 , 0.5f , ref_offset , 16 );
185+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_offset_f16 , 0p5 _23 , in_com1 , 0.5f , ref_offset , 23 );
186+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_offset_f16 , long , in_com1 , 0.5f , ref_offset ,
187187 ARRAY_SIZE (in_com1 ));
188188
189- static void test_arm_scale_f16 (
189+ static void test_zdsp_scale_f16 (
190190 const uint16_t * input1 , float16_t scalar , const uint16_t * ref ,
191191 size_t length )
192192{
@@ -197,7 +197,7 @@ static void test_arm_scale_f16(
197197 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
198198
199199 /* Run test function */
200- arm_scale_f16 ((float16_t * )input1 , scalar , output , length );
200+ zdsp_scale_f16 ((float16_t * )input1 , scalar , output , length );
201201
202202 /* Validate output */
203203 zassert_true (
@@ -214,13 +214,13 @@ static void test_arm_scale_f16(
214214 free (output );
215215}
216216
217- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_scale_f16 , 0p5 _7 , in_com1 , 0.5f , ref_scale , 7 );
218- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_scale_f16 , 0p5 _16 , in_com1 , 0.5f , ref_scale , 16 );
219- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_scale_f16 , 0p5 _23 , in_com1 , 0.5f , ref_scale , 23 );
220- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_scale_f16 , long , in_com1 , 0.5f , ref_scale ,
217+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_scale_f16 , 0p5 _7 , in_com1 , 0.5f , ref_scale , 7 );
218+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_scale_f16 , 0p5 _16 , in_com1 , 0.5f , ref_scale , 16 );
219+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_scale_f16 , 0p5 _23 , in_com1 , 0.5f , ref_scale , 23 );
220+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_scale_f16 , long , in_com1 , 0.5f , ref_scale ,
221221 ARRAY_SIZE (in_com1 ));
222222
223- static void test_arm_dot_prod_f16 (
223+ static void test_zdsp_dot_prod_f16 (
224224 const uint16_t * input1 , const uint16_t * input2 , const uint16_t * ref ,
225225 size_t length )
226226{
@@ -231,7 +231,7 @@ static void test_arm_dot_prod_f16(
231231 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
232232
233233 /* Run test function */
234- arm_dot_prod_f16 (
234+ zdsp_dot_prod_f16 (
235235 (float16_t * )input1 , (float16_t * )input2 , length , & output [0 ]);
236236
237237 /* Validate output */
@@ -249,13 +249,13 @@ static void test_arm_dot_prod_f16(
249249 free (output );
250250}
251251
252- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_dot_prod_f16 , 7 , in_com1 , in_com2 , ref_dot_prod_3 , 7 );
253- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_dot_prod_f16 , 16 , in_com1 , in_com2 , ref_dot_prod_4 , 16 );
254- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_dot_prod_f16 , 23 , in_com1 , in_com2 , ref_dot_prod_4n1 , 23 );
255- DEFINE_TEST_VARIANT4 (basic_math_f16 , arm_dot_prod_f16 , long , in_com1 , in_com2 , ref_dot_prod_long ,
252+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_dot_prod_f16 , 7 , in_com1 , in_com2 , ref_dot_prod_3 , 7 );
253+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_dot_prod_f16 , 16 , in_com1 , in_com2 , ref_dot_prod_4 , 16 );
254+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_dot_prod_f16 , 23 , in_com1 , in_com2 , ref_dot_prod_4n1 , 23 );
255+ DEFINE_TEST_VARIANT4 (basic_math_f16 , zdsp_dot_prod_f16 , long , in_com1 , in_com2 , ref_dot_prod_long ,
256256 ARRAY_SIZE (in_com1 ));
257257
258- static void test_arm_abs_f16 (
258+ static void test_zdsp_abs_f16 (
259259 const uint16_t * input1 , const uint16_t * ref , size_t length )
260260{
261261 float16_t * output ;
@@ -265,7 +265,7 @@ static void test_arm_abs_f16(
265265 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
266266
267267 /* Run test function */
268- arm_abs_f16 ((float16_t * )input1 , output , length );
268+ zdsp_abs_f16 ((float16_t * )input1 , output , length );
269269
270270 /* Validate output */
271271 zassert_true (
@@ -282,12 +282,12 @@ static void test_arm_abs_f16(
282282 free (output );
283283}
284284
285- DEFINE_TEST_VARIANT3 (basic_math_f16 , arm_abs_f16 , 7 , in_com1 , ref_abs , 7 );
286- DEFINE_TEST_VARIANT3 (basic_math_f16 , arm_abs_f16 , 16 , in_com1 , ref_abs , 16 );
287- DEFINE_TEST_VARIANT3 (basic_math_f16 , arm_abs_f16 , 23 , in_com1 , ref_abs , 23 );
288- DEFINE_TEST_VARIANT3 (basic_math_f16 , arm_abs_f16 , long , in_com1 , ref_abs , ARRAY_SIZE (in_com1 ));
285+ DEFINE_TEST_VARIANT3 (basic_math_f16 , zdsp_abs_f16 , 7 , in_com1 , ref_abs , 7 );
286+ DEFINE_TEST_VARIANT3 (basic_math_f16 , zdsp_abs_f16 , 16 , in_com1 , ref_abs , 16 );
287+ DEFINE_TEST_VARIANT3 (basic_math_f16 , zdsp_abs_f16 , 23 , in_com1 , ref_abs , 23 );
288+ DEFINE_TEST_VARIANT3 (basic_math_f16 , zdsp_abs_f16 , long , in_com1 , ref_abs , ARRAY_SIZE (in_com1 ));
289289
290- static void test_arm_clip_f16 (
290+ static void test_zdsp_clip_f16 (
291291 const uint16_t * input , const uint16_t * ref , float16_t min , float16_t max , size_t length )
292292{
293293 float16_t * output ;
@@ -297,7 +297,7 @@ static void test_arm_clip_f16(
297297 zassert_not_null (output , ASSERT_MSG_BUFFER_ALLOC_FAILED );
298298
299299 /* Run test function */
300- arm_clip_f16 ((float16_t * )input , output , min , max , length );
300+ zdsp_clip_f16 ((float16_t * )input , output , min , max , length );
301301
302302 /* Validate output */
303303 zassert_true (
@@ -314,11 +314,11 @@ static void test_arm_clip_f16(
314314 free (output );
315315}
316316
317- DEFINE_TEST_VARIANT5 (basic_math_f16 , arm_clip_f16 , m0p5_m0p1 , in_clip , ref_clip1 ,
317+ DEFINE_TEST_VARIANT5 (basic_math_f16 , zdsp_clip_f16 , m0p5_m0p1 , in_clip , ref_clip1 ,
318318 -0.5f , -0.1f , ARRAY_SIZE (ref_clip1 ));
319- DEFINE_TEST_VARIANT5 (basic_math_f16 , arm_clip_f16 , m0p5_0p5 , in_clip , ref_clip2 ,
319+ DEFINE_TEST_VARIANT5 (basic_math_f16 , zdsp_clip_f16 , m0p5_0p5 , in_clip , ref_clip2 ,
320320 -0.5f , 0.5f , ARRAY_SIZE (ref_clip2 ));
321- DEFINE_TEST_VARIANT5 (basic_math_f16 , arm_clip_f16 , 0p1 _0p5 , in_clip , ref_clip3 ,
321+ DEFINE_TEST_VARIANT5 (basic_math_f16 , zdsp_clip_f16 , 0p1 _0p5 , in_clip , ref_clip3 ,
322322 0.1f , 0.5f , ARRAY_SIZE (ref_clip3 ));
323323
324324ZTEST_SUITE (basic_math_f16 , NULL , NULL , NULL , NULL , NULL );
0 commit comments