ztest API Migration: lib/cmsis_dsp
Migrate some of the unit tests at `lib/cmsis_dsp` to the new ztest API: * lib/cmsis_dsp/basicmath * lib/cmsis_dsp/bayes * lib/cmsis_dsp/complexmath * lib/cmsis_dsp/distance * lib/cmsis_dsp/fastmath `lib/cmsis_dsp/common/test_common.h` has been adapted to use the new ztest API for the test variant macros, when enabled. Signed-off-by: Tristan Honscheid <honscheid@google.com>
This commit is contained in:
parent
8283eb3b54
commit
2abb2389a1
34 changed files with 535 additions and 1010 deletions
|
@ -9,7 +9,6 @@ target_sources(app PRIVATE
|
|||
src/q15.c
|
||||
src/q31.c
|
||||
src/f32.c
|
||||
src/main.c
|
||||
)
|
||||
|
||||
target_sources_ifdef(CONFIG_CMSIS_DSP_FLOAT16 app PRIVATE src/f16.c)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
CONFIG_CMSIS_DSP=y
|
||||
CONFIG_CMSIS_DSP_BASICMATH=y
|
||||
|
|
|
@ -45,10 +45,11 @@ static void test_arm_add_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_add_f16, 7, in_com1, in_com2, ref_add, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_add_f16, 16, in_com1, in_com2, ref_add, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_add_f16, 23, in_com1, in_com2, ref_add, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_add_f16, long, in_com1, in_com2, ref_add, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_add_f16, 7, in_com1, in_com2, ref_add, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_add_f16, 16, in_com1, in_com2, ref_add, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_add_f16, 23, in_com1, in_com2, ref_add, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_add_f16, long, in_com1, in_com2, ref_add,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_sub_f16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -78,10 +79,11 @@ static void test_arm_sub_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_sub_f16, 7, in_com1, in_com2, ref_sub, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_f16, 16, in_com1, in_com2, ref_sub, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_f16, 23, in_com1, in_com2, ref_sub, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_f16, long, in_com1, in_com2, ref_sub, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_sub_f16, 7, in_com1, in_com2, ref_sub, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_sub_f16, 16, in_com1, in_com2, ref_sub, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_sub_f16, 23, in_com1, in_com2, ref_sub, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_sub_f16, long, in_com1, in_com2, ref_sub,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_mult_f16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -111,10 +113,11 @@ static void test_arm_mult_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_mult_f16, 7, in_com1, in_com2, ref_mult, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_f16, 16, in_com1, in_com2, ref_mult, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_f16, 23, in_com1, in_com2, ref_mult, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_f16, long, in_com1, in_com2, ref_mult, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_mult_f16, 7, in_com1, in_com2, ref_mult, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_mult_f16, 16, in_com1, in_com2, ref_mult, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_mult_f16, 23, in_com1, in_com2, ref_mult, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_mult_f16, long, in_com1, in_com2, ref_mult,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_negate_f16(
|
||||
const uint16_t *input1, const uint16_t *ref, size_t length)
|
||||
|
@ -143,10 +146,11 @@ static void test_arm_negate_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_negate_f16, 7, in_com1, ref_negate, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_f16, 16, in_com1, ref_negate, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_f16, 23, in_com1, ref_negate, 23);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_f16, long, in_com1, ref_negate, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_f16, arm_negate_f16, 7, in_com1, ref_negate, 7);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f16, arm_negate_f16, 16, in_com1, ref_negate, 16);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f16, arm_negate_f16, 23, in_com1, ref_negate, 23);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f16, arm_negate_f16, long, in_com1, ref_negate,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_offset_f16(
|
||||
const uint16_t *input1, float16_t scalar, const uint16_t *ref,
|
||||
|
@ -176,10 +180,11 @@ static void test_arm_offset_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_offset_f16, 0p5_7, in_com1, 0.5f, ref_offset, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_f16, 0p5_16, in_com1, 0.5f, ref_offset, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_f16, 0p5_23, in_com1, 0.5f, ref_offset, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_f16, long, in_com1, 0.5f, ref_offset, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_offset_f16, 0p5_7, in_com1, 0.5f, ref_offset, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_offset_f16, 0p5_16, in_com1, 0.5f, ref_offset, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_offset_f16, 0p5_23, in_com1, 0.5f, ref_offset, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_offset_f16, long, in_com1, 0.5f, ref_offset,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_scale_f16(
|
||||
const uint16_t *input1, float16_t scalar, const uint16_t *ref,
|
||||
|
@ -209,10 +214,11 @@ static void test_arm_scale_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_scale_f16, 0p5_7, in_com1, 0.5f, ref_scale, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_f16, 0p5_16, in_com1, 0.5f, ref_scale, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_f16, 0p5_23, in_com1, 0.5f, ref_scale, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_f16, long, in_com1, 0.5f, ref_scale, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_scale_f16, 0p5_7, in_com1, 0.5f, ref_scale, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_scale_f16, 0p5_16, in_com1, 0.5f, ref_scale, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_scale_f16, 0p5_23, in_com1, 0.5f, ref_scale, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_scale_f16, long, in_com1, 0.5f, ref_scale,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_dot_prod_f16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -243,10 +249,10 @@ static void test_arm_dot_prod_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_f16, 7, in_com1, in_com2, ref_dot_prod_3, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_f16, 16, in_com1, in_com2, ref_dot_prod_4, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_f16, 23, in_com1, in_com2, ref_dot_prod_4n1, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_f16, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_dot_prod_f16, 7, in_com1, in_com2, ref_dot_prod_3, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_dot_prod_f16, 16, in_com1, in_com2, ref_dot_prod_4, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_dot_prod_f16, 23, in_com1, in_com2, ref_dot_prod_4n1, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f16, arm_dot_prod_f16, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_abs_f16(
|
||||
|
@ -276,10 +282,10 @@ static void test_arm_abs_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_abs_f16, 7, in_com1, ref_abs, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_f16, 16, in_com1, ref_abs, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_f16, 23, in_com1, ref_abs, 23);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_f16, long, in_com1, ref_abs, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_f16, arm_abs_f16, 7, in_com1, ref_abs, 7);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f16, arm_abs_f16, 16, in_com1, ref_abs, 16);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f16, arm_abs_f16, 23, in_com1, ref_abs, 23);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f16, arm_abs_f16, long, in_com1, ref_abs, ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_clip_f16(
|
||||
const uint16_t *input, const uint16_t *ref, float16_t min, float16_t max, size_t length)
|
||||
|
@ -308,52 +314,11 @@ static void test_arm_clip_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT5(arm_clip_f16, m0p5_m0p1, in_clip, ref_clip1,
|
||||
DEFINE_TEST_VARIANT5(basic_math_f16, arm_clip_f16, m0p5_m0p1, in_clip, ref_clip1,
|
||||
-0.5f, -0.1f, ARRAY_SIZE(ref_clip1));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_f16, m0p5_0p5, in_clip, ref_clip2,
|
||||
DEFINE_TEST_VARIANT5(basic_math_f16, arm_clip_f16, m0p5_0p5, in_clip, ref_clip2,
|
||||
-0.5f, 0.5f, ARRAY_SIZE(ref_clip2));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_f16, 0p1_0p5, in_clip, ref_clip3,
|
||||
DEFINE_TEST_VARIANT5(basic_math_f16, arm_clip_f16, 0p1_0p5, in_clip, ref_clip3,
|
||||
0.1f, 0.5f, ARRAY_SIZE(ref_clip3));
|
||||
|
||||
void test_basicmath_f16(void)
|
||||
{
|
||||
ztest_test_suite(basicmath_f16,
|
||||
ztest_unit_test(test_arm_add_f16_7),
|
||||
ztest_unit_test(test_arm_add_f16_16),
|
||||
ztest_unit_test(test_arm_add_f16_23),
|
||||
ztest_unit_test(test_arm_sub_f16_7),
|
||||
ztest_unit_test(test_arm_sub_f16_16),
|
||||
ztest_unit_test(test_arm_sub_f16_23),
|
||||
ztest_unit_test(test_arm_mult_f16_7),
|
||||
ztest_unit_test(test_arm_mult_f16_16),
|
||||
ztest_unit_test(test_arm_mult_f16_23),
|
||||
ztest_unit_test(test_arm_negate_f16_7),
|
||||
ztest_unit_test(test_arm_negate_f16_16),
|
||||
ztest_unit_test(test_arm_negate_f16_23),
|
||||
ztest_unit_test(test_arm_offset_f16_0p5_7),
|
||||
ztest_unit_test(test_arm_offset_f16_0p5_16),
|
||||
ztest_unit_test(test_arm_offset_f16_0p5_23),
|
||||
ztest_unit_test(test_arm_scale_f16_0p5_7),
|
||||
ztest_unit_test(test_arm_scale_f16_0p5_16),
|
||||
ztest_unit_test(test_arm_scale_f16_0p5_23),
|
||||
ztest_unit_test(test_arm_dot_prod_f16_7),
|
||||
ztest_unit_test(test_arm_dot_prod_f16_16),
|
||||
ztest_unit_test(test_arm_dot_prod_f16_23),
|
||||
ztest_unit_test(test_arm_abs_f16_7),
|
||||
ztest_unit_test(test_arm_abs_f16_16),
|
||||
ztest_unit_test(test_arm_abs_f16_23),
|
||||
ztest_unit_test(test_arm_add_f16_long),
|
||||
ztest_unit_test(test_arm_sub_f16_long),
|
||||
ztest_unit_test(test_arm_mult_f16_long),
|
||||
ztest_unit_test(test_arm_negate_f16_long),
|
||||
ztest_unit_test(test_arm_offset_f16_long),
|
||||
ztest_unit_test(test_arm_scale_f16_long),
|
||||
ztest_unit_test(test_arm_dot_prod_f16_long),
|
||||
ztest_unit_test(test_arm_abs_f16_long),
|
||||
ztest_unit_test(test_arm_clip_f16_m0p5_m0p1),
|
||||
ztest_unit_test(test_arm_clip_f16_m0p5_0p5),
|
||||
ztest_unit_test(test_arm_clip_f16_0p1_0p5)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(basicmath_f16);
|
||||
}
|
||||
ZTEST_SUITE(basic_math_f16, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
|
@ -44,10 +44,11 @@ static void test_arm_add_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_add_f32, 3, in_com1, in_com2, ref_add, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_add_f32, 8, in_com1, in_com2, ref_add, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_add_f32, 11, in_com1, in_com2, ref_add, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_add_f32, long, in_com1, in_com2, ref_add, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_add_f32, 3, in_com1, in_com2, ref_add, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_add_f32, 8, in_com1, in_com2, ref_add, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_add_f32, 11, in_com1, in_com2, ref_add, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_add_f32, long, in_com1, in_com2, ref_add,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_sub_f32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref,
|
||||
|
@ -77,10 +78,11 @@ static void test_arm_sub_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_sub_f32, 3, in_com1, in_com2, ref_sub, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_f32, 8, in_com1, in_com2, ref_sub, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_f32, 11, in_com1, in_com2, ref_sub, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_f32, long, in_com1, in_com2, ref_sub, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_sub_f32, 3, in_com1, in_com2, ref_sub, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_sub_f32, 8, in_com1, in_com2, ref_sub, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_sub_f32, 11, in_com1, in_com2, ref_sub, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_sub_f32, long, in_com1, in_com2, ref_sub,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_mult_f32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref,
|
||||
|
@ -110,10 +112,11 @@ static void test_arm_mult_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_mult_f32, 3, in_com1, in_com2, ref_mult, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_f32, 8, in_com1, in_com2, ref_mult, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_f32, 11, in_com1, in_com2, ref_mult, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_f32, long, in_com1, in_com2, ref_mult, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_mult_f32, 3, in_com1, in_com2, ref_mult, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_mult_f32, 8, in_com1, in_com2, ref_mult, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_mult_f32, 11, in_com1, in_com2, ref_mult, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_mult_f32, long, in_com1, in_com2, ref_mult,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_negate_f32(
|
||||
const uint32_t *input1, const uint32_t *ref, size_t length)
|
||||
|
@ -142,10 +145,11 @@ static void test_arm_negate_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_negate_f32, 3, in_com1, ref_negate, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_f32, 8, in_com1, ref_negate, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_f32, 11, in_com1, ref_negate, 11);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_f32, long, in_com1, ref_negate, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_f32, arm_negate_f32, 3, in_com1, ref_negate, 3);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f32, arm_negate_f32, 8, in_com1, ref_negate, 8);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f32, arm_negate_f32, 11, in_com1, ref_negate, 11);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f32, arm_negate_f32, long, in_com1, ref_negate,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_offset_f32(
|
||||
const uint32_t *input1, float32_t scalar, const uint32_t *ref,
|
||||
|
@ -175,10 +179,11 @@ static void test_arm_offset_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_offset_f32, 0p5_3, in_com1, 0.5f, ref_offset, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_f32, 0p5_8, in_com1, 0.5f, ref_offset, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_f32, 0p5_11, in_com1, 0.5f, ref_offset, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_f32, long, in_com1, 0.5f, ref_offset, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_offset_f32, 0p5_3, in_com1, 0.5f, ref_offset, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_offset_f32, 0p5_8, in_com1, 0.5f, ref_offset, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_offset_f32, 0p5_11, in_com1, 0.5f, ref_offset, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_offset_f32, long, in_com1, 0.5f, ref_offset,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_scale_f32(
|
||||
const uint32_t *input1, float32_t scalar, const uint32_t *ref,
|
||||
|
@ -208,10 +213,11 @@ static void test_arm_scale_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_scale_f32, 0p5_3, in_com1, 0.5f, ref_scale, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_f32, 0p5_8, in_com1, 0.5f, ref_scale, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_f32, 0p5_11, in_com1, 0.5f, ref_scale, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_f32, long, in_com1, 0.5f, ref_scale, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_scale_f32, 0p5_3, in_com1, 0.5f, ref_scale, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_scale_f32, 0p5_8, in_com1, 0.5f, ref_scale, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_scale_f32, 0p5_11, in_com1, 0.5f, ref_scale, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_scale_f32, long, in_com1, 0.5f, ref_scale,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_dot_prod_f32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref,
|
||||
|
@ -242,10 +248,10 @@ static void test_arm_dot_prod_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_f32, 3, in_com1, in_com2, ref_dot_prod_3, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_f32, 8, in_com1, in_com2, ref_dot_prod_4, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_f32, 11, in_com1, in_com2, ref_dot_prod_4n1, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_f32, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_dot_prod_f32, 3, in_com1, in_com2, ref_dot_prod_3, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_dot_prod_f32, 8, in_com1, in_com2, ref_dot_prod_4, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_dot_prod_f32, 11, in_com1, in_com2, ref_dot_prod_4n1, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_f32, arm_dot_prod_f32, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_abs_f32(
|
||||
|
@ -275,10 +281,10 @@ static void test_arm_abs_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_abs_f32, 3, in_com1, ref_abs, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_f32, 8, in_com1, ref_abs, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_f32, 11, in_com1, ref_abs, 11);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_f32, long, in_com1, ref_abs, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_f32, arm_abs_f32, 3, in_com1, ref_abs, 3);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f32, arm_abs_f32, 8, in_com1, ref_abs, 8);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f32, arm_abs_f32, 11, in_com1, ref_abs, 11);
|
||||
DEFINE_TEST_VARIANT3(basic_math_f32, arm_abs_f32, long, in_com1, ref_abs, ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_clip_f32(
|
||||
const uint32_t *input, const uint32_t *ref, float32_t min, float32_t max, size_t length)
|
||||
|
@ -307,52 +313,11 @@ static void test_arm_clip_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT5(arm_clip_f32, m0p5_m0p1, in_clip, ref_clip1,
|
||||
DEFINE_TEST_VARIANT5(basic_math_f32, arm_clip_f32, m0p5_m0p1, in_clip, ref_clip1,
|
||||
-0.5f, -0.1f, ARRAY_SIZE(ref_clip1));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_f32, m0p5_0p5, in_clip, ref_clip2,
|
||||
DEFINE_TEST_VARIANT5(basic_math_f32, arm_clip_f32, m0p5_0p5, in_clip, ref_clip2,
|
||||
-0.5f, 0.5f, ARRAY_SIZE(ref_clip2));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_f32, 0p1_0p5, in_clip, ref_clip3,
|
||||
DEFINE_TEST_VARIANT5(basic_math_f32, arm_clip_f32, 0p1_0p5, in_clip, ref_clip3,
|
||||
0.1f, 0.5f, ARRAY_SIZE(ref_clip3));
|
||||
|
||||
void test_basicmath_f32(void)
|
||||
{
|
||||
ztest_test_suite(basicmath_f32,
|
||||
ztest_unit_test(test_arm_add_f32_3),
|
||||
ztest_unit_test(test_arm_add_f32_8),
|
||||
ztest_unit_test(test_arm_add_f32_11),
|
||||
ztest_unit_test(test_arm_sub_f32_3),
|
||||
ztest_unit_test(test_arm_sub_f32_8),
|
||||
ztest_unit_test(test_arm_sub_f32_11),
|
||||
ztest_unit_test(test_arm_mult_f32_3),
|
||||
ztest_unit_test(test_arm_mult_f32_8),
|
||||
ztest_unit_test(test_arm_mult_f32_11),
|
||||
ztest_unit_test(test_arm_negate_f32_3),
|
||||
ztest_unit_test(test_arm_negate_f32_8),
|
||||
ztest_unit_test(test_arm_negate_f32_11),
|
||||
ztest_unit_test(test_arm_offset_f32_0p5_3),
|
||||
ztest_unit_test(test_arm_offset_f32_0p5_8),
|
||||
ztest_unit_test(test_arm_offset_f32_0p5_11),
|
||||
ztest_unit_test(test_arm_scale_f32_0p5_3),
|
||||
ztest_unit_test(test_arm_scale_f32_0p5_8),
|
||||
ztest_unit_test(test_arm_scale_f32_0p5_11),
|
||||
ztest_unit_test(test_arm_dot_prod_f32_3),
|
||||
ztest_unit_test(test_arm_dot_prod_f32_8),
|
||||
ztest_unit_test(test_arm_dot_prod_f32_11),
|
||||
ztest_unit_test(test_arm_abs_f32_3),
|
||||
ztest_unit_test(test_arm_abs_f32_8),
|
||||
ztest_unit_test(test_arm_abs_f32_11),
|
||||
ztest_unit_test(test_arm_add_f32_long),
|
||||
ztest_unit_test(test_arm_sub_f32_long),
|
||||
ztest_unit_test(test_arm_mult_f32_long),
|
||||
ztest_unit_test(test_arm_negate_f32_long),
|
||||
ztest_unit_test(test_arm_offset_f32_long),
|
||||
ztest_unit_test(test_arm_scale_f32_long),
|
||||
ztest_unit_test(test_arm_dot_prod_f32_long),
|
||||
ztest_unit_test(test_arm_abs_f32_long),
|
||||
ztest_unit_test(test_arm_clip_f32_m0p5_m0p1),
|
||||
ztest_unit_test(test_arm_clip_f32_m0p5_0p5),
|
||||
ztest_unit_test(test_arm_clip_f32_0p1_0p5)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(basicmath_f32);
|
||||
}
|
||||
ZTEST_SUITE(basic_math_f32, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 Stephanos Ioannidis <root@stephanos.io>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <zephyr.h>
|
||||
|
||||
extern void test_basicmath_q7(void);
|
||||
extern void test_basicmath_q15(void);
|
||||
extern void test_basicmath_q31(void);
|
||||
extern void test_basicmath_f16(void);
|
||||
extern void test_basicmath_f32(void);
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
test_basicmath_q7();
|
||||
test_basicmath_q15();
|
||||
test_basicmath_q31();
|
||||
#ifdef CONFIG_CMSIS_DSP_FLOAT16
|
||||
test_basicmath_f16();
|
||||
#endif
|
||||
test_basicmath_f32();
|
||||
}
|
|
@ -44,12 +44,13 @@ static void test_arm_add_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_add_q15, 7, in_com1, in_com2, ref_add, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q15, 16, in_com1, in_com2, ref_add, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q15, 23, in_com1, in_com2, ref_add, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q15, possat, in_maxpos, in_maxpos, ref_add_possat, 17);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q15, negsat, in_maxneg, in_maxneg, ref_add_negsat, 17);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q15, long, in_com1, in_com2, ref_add, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_add_q15, 7, in_com1, in_com2, ref_add, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_add_q15, 16, in_com1, in_com2, ref_add, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_add_q15, 23, in_com1, in_com2, ref_add, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_add_q15, possat, in_maxpos, in_maxpos, ref_add_possat, 17);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_add_q15, negsat, in_maxneg, in_maxneg, ref_add_negsat, 17);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_add_q15, long, in_com1, in_com2, ref_add,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_sub_q15(
|
||||
const q15_t *input1, const q15_t *input2, const q15_t *ref,
|
||||
|
@ -77,12 +78,13 @@ static void test_arm_sub_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q15, 7, in_com1, in_com2, ref_sub, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q15, 16, in_com1, in_com2, ref_sub, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q15, 23, in_com1, in_com2, ref_sub, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q15, possat, in_maxpos, in_maxneg, ref_sub_possat, 17);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q15, negsat, in_maxneg, in_maxpos, ref_sub_negsat, 17);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q15, long, in_com1, in_com2, ref_sub, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_sub_q15, 7, in_com1, in_com2, ref_sub, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_sub_q15, 16, in_com1, in_com2, ref_sub, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_sub_q15, 23, in_com1, in_com2, ref_sub, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_sub_q15, possat, in_maxpos, in_maxneg, ref_sub_possat, 17);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_sub_q15, negsat, in_maxneg, in_maxpos, ref_sub_negsat, 17);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_sub_q15, long, in_com1, in_com2, ref_sub,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_mult_q15(
|
||||
const q15_t *input1, const q15_t *input2, const q15_t *ref,
|
||||
|
@ -110,11 +112,13 @@ static void test_arm_mult_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q15, 7, in_com1, in_com2, ref_mult, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q15, 16, in_com1, in_com2, ref_mult, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q15, 23, in_com1, in_com2, ref_mult, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q15, possat, in_maxneg2, in_maxneg2, ref_mult_possat, 17);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q15, long, in_com1, in_com2, ref_mult, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_mult_q15, 7, in_com1, in_com2, ref_mult, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_mult_q15, 16, in_com1, in_com2, ref_mult, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_mult_q15, 23, in_com1, in_com2, ref_mult, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_mult_q15, possat, in_maxneg2, in_maxneg2, ref_mult_possat,
|
||||
17);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_mult_q15, long, in_com1, in_com2, ref_mult,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_negate_q15(
|
||||
const q15_t *input1, const q15_t *ref, size_t length)
|
||||
|
@ -141,11 +145,12 @@ static void test_arm_negate_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q15, 7, in_com1, ref_negate, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q15, 16, in_com1, ref_negate, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q15, 23, in_com1, ref_negate, 23);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q15, possat, in_maxneg2, ref_negate_possat, 17);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q15, long, in_com1, ref_negate, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_negate_q15, 7, in_com1, ref_negate, 7);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_negate_q15, 16, in_com1, ref_negate, 16);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_negate_q15, 23, in_com1, ref_negate, 23);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_negate_q15, possat, in_maxneg2, ref_negate_possat, 17);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_negate_q15, long, in_com1, ref_negate,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_offset_q15(
|
||||
const q15_t *input1, q15_t scalar, const q15_t *ref, size_t length)
|
||||
|
@ -172,12 +177,15 @@ static void test_arm_offset_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q15, 0p5_7, in_com1, 0x4000, ref_offset, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q15, 0p5_16, in_com1, 0x4000, ref_offset, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q15, 0p5_23, in_com1, 0x4000, ref_offset, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q15, possat, in_maxpos, 0x7333, ref_offset_possat, 17);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q15, negsat, in_maxneg, 0x8ccd, ref_offset_negsat, 17);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q15, long, in_com1, 0x4000, ref_offset, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_offset_q15, 0p5_7, in_com1, 0x4000, ref_offset, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_offset_q15, 0p5_16, in_com1, 0x4000, ref_offset, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_offset_q15, 0p5_23, in_com1, 0x4000, ref_offset, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_offset_q15, possat, in_maxpos, 0x7333, ref_offset_possat,
|
||||
17);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_offset_q15, negsat, in_maxneg, 0x8ccd, ref_offset_negsat,
|
||||
17);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_offset_q15, long, in_com1, 0x4000, ref_offset,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_scale_q15(
|
||||
const q15_t *input1, q15_t scalar, const q15_t *ref, size_t length)
|
||||
|
@ -204,11 +212,13 @@ static void test_arm_scale_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q15, 0p5_7, in_com1, 0x4000, ref_scale, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q15, 0p5_16, in_com1, 0x4000, ref_scale, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q15, 0p5_23, in_com1, 0x4000, ref_scale, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q15, possat, in_maxneg2, 0x8000, ref_scale_possat, 17);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q15, long, in_com1, 0x4000, ref_scale, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_scale_q15, 0p5_7, in_com1, 0x4000, ref_scale, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_scale_q15, 0p5_16, in_com1, 0x4000, ref_scale, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_scale_q15, 0p5_23, in_com1, 0x4000, ref_scale, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_scale_q15, possat, in_maxneg2, 0x8000, ref_scale_possat,
|
||||
17);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_scale_q15, long, in_com1, 0x4000, ref_scale,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_dot_prod_q15(
|
||||
const q15_t *input1, const q15_t *input2, const q63_t *ref,
|
||||
|
@ -236,10 +246,10 @@ static void test_arm_dot_prod_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q15, 7, in_com1, in_com2, ref_dot_prod_3, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q15, 16, in_com1, in_com2, ref_dot_prod_4, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q15, 23, in_com1, in_com2, ref_dot_prod_4n1, 23);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q15, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_dot_prod_q15, 7, in_com1, in_com2, ref_dot_prod_3, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_dot_prod_q15, 16, in_com1, in_com2, ref_dot_prod_4, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_dot_prod_q15, 23, in_com1, in_com2, ref_dot_prod_4n1, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_dot_prod_q15, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_abs_q15(
|
||||
|
@ -267,10 +277,10 @@ static void test_arm_abs_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q15, 7, in_com1, ref_abs, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q15, 16, in_com1, ref_abs, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q15, 23, in_com1, ref_abs, 23);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q15, long, in_com1, ref_abs, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_abs_q15, 7, in_com1, ref_abs, 7);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_abs_q15, 16, in_com1, ref_abs, 16);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_abs_q15, 23, in_com1, ref_abs, 23);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_abs_q15, long, in_com1, ref_abs, ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_shift_q15(
|
||||
const q15_t *input1, const q15_t *ref, size_t length)
|
||||
|
@ -297,9 +307,9 @@ static void test_arm_shift_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q15, rand, in_rand, ref_shift, 17);
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q15, possat, in_maxpos, ref_shift_possat, 17);
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q15, negsat, in_maxneg, ref_shift_negsat, 17);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_shift_q15, rand, in_rand, ref_shift, 17);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_shift_q15, possat, in_maxpos, ref_shift_possat, 17);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_shift_q15, negsat, in_maxneg, ref_shift_negsat, 17);
|
||||
|
||||
static void test_arm_and_u16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -323,9 +333,9 @@ static void test_arm_and_u16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_and_u16, 7, in_bitwise1, in_bitwise2, ref_and, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_and_u16, 16, in_bitwise1, in_bitwise2, ref_and, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_and_u16, 23, in_bitwise1, in_bitwise2, ref_and, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_and_u16, 7, in_bitwise1, in_bitwise2, ref_and, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_and_u16, 16, in_bitwise1, in_bitwise2, ref_and, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_and_u16, 23, in_bitwise1, in_bitwise2, ref_and, 23);
|
||||
|
||||
static void test_arm_or_u16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -349,9 +359,9 @@ static void test_arm_or_u16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_or_u16, 7, in_bitwise1, in_bitwise2, ref_or, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_or_u16, 16, in_bitwise1, in_bitwise2, ref_or, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_or_u16, 23, in_bitwise1, in_bitwise2, ref_or, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_or_u16, 7, in_bitwise1, in_bitwise2, ref_or, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_or_u16, 16, in_bitwise1, in_bitwise2, ref_or, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_or_u16, 23, in_bitwise1, in_bitwise2, ref_or, 23);
|
||||
|
||||
static void test_arm_not_u16(
|
||||
const uint16_t *input1, const uint16_t *ref, size_t length)
|
||||
|
@ -374,9 +384,9 @@ static void test_arm_not_u16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_not_u16, 7, in_bitwise1, ref_not, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_not_u16, 16, in_bitwise1, ref_not, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_not_u16, 23, in_bitwise1, ref_not, 23);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_not_u16, 7, in_bitwise1, ref_not, 7);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_not_u16, 16, in_bitwise1, ref_not, 16);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q15, arm_not_u16, 23, in_bitwise1, ref_not, 23);
|
||||
|
||||
static void test_arm_xor_u16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -400,9 +410,9 @@ static void test_arm_xor_u16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u16, 7, in_bitwise1, in_bitwise2, ref_xor, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u16, 16, in_bitwise1, in_bitwise2, ref_xor, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u16, 23, in_bitwise1, in_bitwise2, ref_xor, 23);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_xor_u16, 7, in_bitwise1, in_bitwise2, ref_xor, 7);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_xor_u16, 16, in_bitwise1, in_bitwise2, ref_xor, 16);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q15, arm_xor_u16, 23, in_bitwise1, in_bitwise2, ref_xor, 23);
|
||||
|
||||
static void test_arm_clip_q15(
|
||||
const q15_t *input, const q15_t *ref, q15_t min, q15_t max, size_t length)
|
||||
|
@ -425,76 +435,11 @@ static void test_arm_clip_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q15, c000_f333, in_clip, ref_clip1,
|
||||
DEFINE_TEST_VARIANT5(basic_math_q15, arm_clip_q15, c000_f333, in_clip, ref_clip1,
|
||||
0xc000, 0xf333, ARRAY_SIZE(ref_clip1));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q15, c000_4000, in_clip, ref_clip2,
|
||||
DEFINE_TEST_VARIANT5(basic_math_q15, arm_clip_q15, c000_4000, in_clip, ref_clip2,
|
||||
0xc000, 0x4000, ARRAY_SIZE(ref_clip2));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q15, 0ccd_4000, in_clip, ref_clip3,
|
||||
DEFINE_TEST_VARIANT5(basic_math_q15, arm_clip_q15, 0ccd_4000, in_clip, ref_clip3,
|
||||
0x0ccd, 0x4000, ARRAY_SIZE(ref_clip3));
|
||||
|
||||
void test_basicmath_q15(void)
|
||||
{
|
||||
ztest_test_suite(basicmath_q15,
|
||||
ztest_unit_test(test_arm_add_q15_7),
|
||||
ztest_unit_test(test_arm_add_q15_16),
|
||||
ztest_unit_test(test_arm_add_q15_23),
|
||||
ztest_unit_test(test_arm_sub_q15_7),
|
||||
ztest_unit_test(test_arm_sub_q15_16),
|
||||
ztest_unit_test(test_arm_sub_q15_23),
|
||||
ztest_unit_test(test_arm_mult_q15_7),
|
||||
ztest_unit_test(test_arm_mult_q15_16),
|
||||
ztest_unit_test(test_arm_mult_q15_23),
|
||||
ztest_unit_test(test_arm_negate_q15_7),
|
||||
ztest_unit_test(test_arm_negate_q15_16),
|
||||
ztest_unit_test(test_arm_negate_q15_23),
|
||||
ztest_unit_test(test_arm_offset_q15_0p5_7),
|
||||
ztest_unit_test(test_arm_offset_q15_0p5_16),
|
||||
ztest_unit_test(test_arm_offset_q15_0p5_23),
|
||||
ztest_unit_test(test_arm_scale_q15_0p5_7),
|
||||
ztest_unit_test(test_arm_scale_q15_0p5_16),
|
||||
ztest_unit_test(test_arm_scale_q15_0p5_23),
|
||||
ztest_unit_test(test_arm_dot_prod_q15_7),
|
||||
ztest_unit_test(test_arm_dot_prod_q15_16),
|
||||
ztest_unit_test(test_arm_dot_prod_q15_23),
|
||||
ztest_unit_test(test_arm_abs_q15_7),
|
||||
ztest_unit_test(test_arm_abs_q15_16),
|
||||
ztest_unit_test(test_arm_abs_q15_23),
|
||||
ztest_unit_test(test_arm_shift_q15_rand),
|
||||
ztest_unit_test(test_arm_add_q15_possat),
|
||||
ztest_unit_test(test_arm_add_q15_negsat),
|
||||
ztest_unit_test(test_arm_sub_q15_possat),
|
||||
ztest_unit_test(test_arm_sub_q15_negsat),
|
||||
ztest_unit_test(test_arm_mult_q15_possat),
|
||||
ztest_unit_test(test_arm_negate_q15_possat),
|
||||
ztest_unit_test(test_arm_offset_q15_possat),
|
||||
ztest_unit_test(test_arm_offset_q15_negsat),
|
||||
ztest_unit_test(test_arm_scale_q15_possat),
|
||||
ztest_unit_test(test_arm_shift_q15_possat),
|
||||
ztest_unit_test(test_arm_shift_q15_negsat),
|
||||
ztest_unit_test(test_arm_and_u16_7),
|
||||
ztest_unit_test(test_arm_and_u16_16),
|
||||
ztest_unit_test(test_arm_and_u16_23),
|
||||
ztest_unit_test(test_arm_or_u16_7),
|
||||
ztest_unit_test(test_arm_or_u16_16),
|
||||
ztest_unit_test(test_arm_or_u16_23),
|
||||
ztest_unit_test(test_arm_not_u16_7),
|
||||
ztest_unit_test(test_arm_not_u16_16),
|
||||
ztest_unit_test(test_arm_not_u16_23),
|
||||
ztest_unit_test(test_arm_xor_u16_7),
|
||||
ztest_unit_test(test_arm_xor_u16_16),
|
||||
ztest_unit_test(test_arm_xor_u16_23),
|
||||
ztest_unit_test(test_arm_add_q15_long),
|
||||
ztest_unit_test(test_arm_sub_q15_long),
|
||||
ztest_unit_test(test_arm_mult_q15_long),
|
||||
ztest_unit_test(test_arm_negate_q15_long),
|
||||
ztest_unit_test(test_arm_offset_q15_long),
|
||||
ztest_unit_test(test_arm_scale_q15_long),
|
||||
ztest_unit_test(test_arm_dot_prod_q15_long),
|
||||
ztest_unit_test(test_arm_abs_q15_long),
|
||||
ztest_unit_test(test_arm_clip_q15_c000_f333),
|
||||
ztest_unit_test(test_arm_clip_q15_c000_4000),
|
||||
ztest_unit_test(test_arm_clip_q15_0ccd_4000)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(basicmath_q15);
|
||||
}
|
||||
ZTEST_SUITE(basic_math_q15, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
|
@ -42,12 +42,13 @@ static void test_arm_add_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_add_q31, 3, in_com1, in_com2, ref_add, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q31, 8, in_com1, in_com2, ref_add, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q31, 11, in_com1, in_com2, ref_add, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q31, possat, in_maxpos, in_maxpos, ref_add_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q31, negsat, in_maxneg, in_maxneg, ref_add_negsat, 9);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q31, long, in_com1, in_com2, ref_add, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_add_q31, 3, in_com1, in_com2, ref_add, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_add_q31, 8, in_com1, in_com2, ref_add, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_add_q31, 11, in_com1, in_com2, ref_add, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_add_q31, possat, in_maxpos, in_maxpos, ref_add_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_add_q31, negsat, in_maxneg, in_maxneg, ref_add_negsat, 9);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_add_q31, long, in_com1, in_com2, ref_add,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_sub_q31(
|
||||
const q31_t *input1, const q31_t *input2, const q31_t *ref, size_t length)
|
||||
|
@ -74,12 +75,13 @@ static void test_arm_sub_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q31, 3, in_com1, in_com2, ref_sub, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q31, 8, in_com1, in_com2, ref_sub, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q31, 11, in_com1, in_com2, ref_sub, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q31, possat, in_maxpos, in_maxneg, ref_sub_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q31, negsat, in_maxneg, in_maxpos, ref_sub_negsat, 9);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q31, long, in_com1, in_com2, ref_sub, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_sub_q31, 3, in_com1, in_com2, ref_sub, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_sub_q31, 8, in_com1, in_com2, ref_sub, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_sub_q31, 11, in_com1, in_com2, ref_sub, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_sub_q31, possat, in_maxpos, in_maxneg, ref_sub_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_sub_q31, negsat, in_maxneg, in_maxpos, ref_sub_negsat, 9);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_sub_q31, long, in_com1, in_com2, ref_sub,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_mult_q31(
|
||||
const q31_t *input1, const q31_t *input2, const q31_t *ref, size_t length)
|
||||
|
@ -106,11 +108,13 @@ static void test_arm_mult_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q31, 3, in_com1, in_com2, ref_mult, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q31, 8, in_com1, in_com2, ref_mult, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q31, 11, in_com1, in_com2, ref_mult, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q31, possat, in_maxneg2, in_maxneg2, ref_mult_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q31, long, in_com1, in_com2, ref_mult, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_mult_q31, 3, in_com1, in_com2, ref_mult, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_mult_q31, 8, in_com1, in_com2, ref_mult, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_mult_q31, 11, in_com1, in_com2, ref_mult, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_mult_q31, possat, in_maxneg2, in_maxneg2, ref_mult_possat,
|
||||
9);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_mult_q31, long, in_com1, in_com2, ref_mult,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_negate_q31(
|
||||
const q31_t *input1, const q31_t *ref, size_t length)
|
||||
|
@ -137,11 +141,12 @@ static void test_arm_negate_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q31, 3, in_com1, ref_negate, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q31, 8, in_com1, ref_negate, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q31, 11, in_com1, ref_negate, 11);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q31, possat, in_maxneg2, ref_negate_possat, 9);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q31, long, in_com1, ref_negate, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_negate_q31, 3, in_com1, ref_negate, 3);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_negate_q31, 8, in_com1, ref_negate, 8);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_negate_q31, 11, in_com1, ref_negate, 11);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_negate_q31, possat, in_maxneg2, ref_negate_possat, 9);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_negate_q31, long, in_com1, ref_negate,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_offset_q31(
|
||||
const q31_t *input1, q31_t scalar, const q31_t *ref, size_t length)
|
||||
|
@ -168,12 +173,15 @@ static void test_arm_offset_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q31, 0p5_3, in_com1, 0x40000000, ref_offset, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q31, 0p5_8, in_com1, 0x40000000, ref_offset, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q31, 0p5_11, in_com1, 0x40000000, ref_offset, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q31, possat, in_maxpos, 0x73333333, ref_offset_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q31, negsat, in_maxneg, 0x8ccccccd, ref_offset_negsat, 9);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q31, long, in_com1, 0x40000000, ref_offset, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_offset_q31, 0p5_3, in_com1, 0x40000000, ref_offset, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_offset_q31, 0p5_8, in_com1, 0x40000000, ref_offset, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_offset_q31, 0p5_11, in_com1, 0x40000000, ref_offset, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_offset_q31, possat, in_maxpos, 0x73333333,
|
||||
ref_offset_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_offset_q31, negsat, in_maxneg, 0x8ccccccd,
|
||||
ref_offset_negsat, 9);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_offset_q31, long, in_com1, 0x40000000, ref_offset,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_scale_q31(
|
||||
const q31_t *input1, q31_t scalar, const q31_t *ref, size_t length)
|
||||
|
@ -200,11 +208,13 @@ static void test_arm_scale_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q31, 0p5_3, in_com1, 0x40000000, ref_scale, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q31, 0p5_8, in_com1, 0x40000000, ref_scale, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q31, 0p5_11, in_com1, 0x40000000, ref_scale, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q31, possat, in_maxneg2, 0x80000000, ref_scale_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q31, long, in_com1, 0x40000000, ref_scale, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_scale_q31, 0p5_3, in_com1, 0x40000000, ref_scale, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_scale_q31, 0p5_8, in_com1, 0x40000000, ref_scale, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_scale_q31, 0p5_11, in_com1, 0x40000000, ref_scale, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_scale_q31, possat, in_maxneg2, 0x80000000,
|
||||
ref_scale_possat, 9);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_scale_q31, long, in_com1, 0x40000000, ref_scale,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_dot_prod_q31(
|
||||
const q31_t *input1, const q31_t *input2, const q63_t *ref, size_t length)
|
||||
|
@ -231,10 +241,10 @@ static void test_arm_dot_prod_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q31, 3, in_com1, in_com2, ref_dot_prod_3, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q31, 8, in_com1, in_com2, ref_dot_prod_4, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q31, 11, in_com1, in_com2, ref_dot_prod_4n1, 11);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q31, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_dot_prod_q31, 3, in_com1, in_com2, ref_dot_prod_3, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_dot_prod_q31, 8, in_com1, in_com2, ref_dot_prod_4, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_dot_prod_q31, 11, in_com1, in_com2, ref_dot_prod_4n1, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_dot_prod_q31, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_abs_q31(
|
||||
|
@ -262,10 +272,10 @@ static void test_arm_abs_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q31, 3, in_com1, ref_abs, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q31, 8, in_com1, ref_abs, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q31, 11, in_com1, ref_abs, 11);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q31, long, in_com1, ref_abs, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_abs_q31, 3, in_com1, ref_abs, 3);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_abs_q31, 8, in_com1, ref_abs, 8);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_abs_q31, 11, in_com1, ref_abs, 11);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_abs_q31, long, in_com1, ref_abs, ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_shift_q31(
|
||||
const q31_t *input1, const q31_t *ref, size_t length)
|
||||
|
@ -292,9 +302,9 @@ static void test_arm_shift_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q31, rand, in_rand, ref_shift, 9);
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q31, possat, in_maxpos, ref_shift_possat, 9);
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q31, negsat, in_maxneg, ref_shift_negsat, 9);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_shift_q31, rand, in_rand, ref_shift, 9);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_shift_q31, possat, in_maxpos, ref_shift_possat, 9);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_shift_q31, negsat, in_maxneg, ref_shift_negsat, 9);
|
||||
|
||||
static void test_arm_and_u32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref, size_t length)
|
||||
|
@ -317,9 +327,9 @@ static void test_arm_and_u32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_and_u32, 3, in_bitwise1, in_bitwise2, ref_and, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_and_u32, 8, in_bitwise1, in_bitwise2, ref_and, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_and_u32, 11, in_bitwise1, in_bitwise2, ref_and, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_and_u32, 3, in_bitwise1, in_bitwise2, ref_and, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_and_u32, 8, in_bitwise1, in_bitwise2, ref_and, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_and_u32, 11, in_bitwise1, in_bitwise2, ref_and, 11);
|
||||
|
||||
static void test_arm_or_u32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref, size_t length)
|
||||
|
@ -342,9 +352,9 @@ static void test_arm_or_u32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_or_u32, 3, in_bitwise1, in_bitwise2, ref_or, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_or_u32, 8, in_bitwise1, in_bitwise2, ref_or, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_or_u32, 11, in_bitwise1, in_bitwise2, ref_or, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_or_u32, 3, in_bitwise1, in_bitwise2, ref_or, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_or_u32, 8, in_bitwise1, in_bitwise2, ref_or, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_or_u32, 11, in_bitwise1, in_bitwise2, ref_or, 11);
|
||||
|
||||
static void test_arm_not_u32(
|
||||
const uint32_t *input1, const uint32_t *ref, size_t length)
|
||||
|
@ -367,9 +377,9 @@ static void test_arm_not_u32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_not_u32, 3, in_bitwise1, ref_not, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_not_u32, 8, in_bitwise1, ref_not, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_not_u32, 11, in_bitwise1, ref_not, 11);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_not_u32, 3, in_bitwise1, ref_not, 3);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_not_u32, 8, in_bitwise1, ref_not, 8);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q31, arm_not_u32, 11, in_bitwise1, ref_not, 11);
|
||||
|
||||
static void test_arm_xor_u32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref, size_t length)
|
||||
|
@ -392,9 +402,9 @@ static void test_arm_xor_u32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u32, 3, in_bitwise1, in_bitwise2, ref_xor, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u32, 8, in_bitwise1, in_bitwise2, ref_xor, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u32, 11, in_bitwise1, in_bitwise2, ref_xor, 11);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_xor_u32, 3, in_bitwise1, in_bitwise2, ref_xor, 3);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_xor_u32, 8, in_bitwise1, in_bitwise2, ref_xor, 8);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q31, arm_xor_u32, 11, in_bitwise1, in_bitwise2, ref_xor, 11);
|
||||
|
||||
static void test_arm_clip_q31(
|
||||
const q31_t *input, const q31_t *ref, q31_t min, q31_t max, size_t length)
|
||||
|
@ -417,76 +427,11 @@ static void test_arm_clip_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q31, c0000000_f3333333, in_clip, ref_clip1,
|
||||
DEFINE_TEST_VARIANT5(basic_math_q31, arm_clip_q31, c0000000_f3333333, in_clip, ref_clip1,
|
||||
0xc0000000, 0xf3333333, ARRAY_SIZE(ref_clip1));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q31, c0000000_40000000, in_clip, ref_clip2,
|
||||
DEFINE_TEST_VARIANT5(basic_math_q31, arm_clip_q31, c0000000_40000000, in_clip, ref_clip2,
|
||||
0xc0000000, 0x40000000, ARRAY_SIZE(ref_clip2));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q31, 0ccccccd_40000000, in_clip, ref_clip3,
|
||||
DEFINE_TEST_VARIANT5(basic_math_q31, arm_clip_q31, 0ccccccd_40000000, in_clip, ref_clip3,
|
||||
0x0ccccccd, 0x40000000, ARRAY_SIZE(ref_clip3));
|
||||
|
||||
void test_basicmath_q31(void)
|
||||
{
|
||||
ztest_test_suite(basicmath_q31,
|
||||
ztest_unit_test(test_arm_add_q31_3),
|
||||
ztest_unit_test(test_arm_add_q31_8),
|
||||
ztest_unit_test(test_arm_add_q31_11),
|
||||
ztest_unit_test(test_arm_sub_q31_3),
|
||||
ztest_unit_test(test_arm_sub_q31_8),
|
||||
ztest_unit_test(test_arm_sub_q31_11),
|
||||
ztest_unit_test(test_arm_mult_q31_3),
|
||||
ztest_unit_test(test_arm_mult_q31_8),
|
||||
ztest_unit_test(test_arm_mult_q31_11),
|
||||
ztest_unit_test(test_arm_negate_q31_3),
|
||||
ztest_unit_test(test_arm_negate_q31_8),
|
||||
ztest_unit_test(test_arm_negate_q31_11),
|
||||
ztest_unit_test(test_arm_offset_q31_0p5_3),
|
||||
ztest_unit_test(test_arm_offset_q31_0p5_8),
|
||||
ztest_unit_test(test_arm_offset_q31_0p5_11),
|
||||
ztest_unit_test(test_arm_scale_q31_0p5_3),
|
||||
ztest_unit_test(test_arm_scale_q31_0p5_8),
|
||||
ztest_unit_test(test_arm_scale_q31_0p5_11),
|
||||
ztest_unit_test(test_arm_dot_prod_q31_3),
|
||||
ztest_unit_test(test_arm_dot_prod_q31_8),
|
||||
ztest_unit_test(test_arm_dot_prod_q31_11),
|
||||
ztest_unit_test(test_arm_abs_q31_3),
|
||||
ztest_unit_test(test_arm_abs_q31_8),
|
||||
ztest_unit_test(test_arm_abs_q31_11),
|
||||
ztest_unit_test(test_arm_shift_q31_rand),
|
||||
ztest_unit_test(test_arm_add_q31_possat),
|
||||
ztest_unit_test(test_arm_add_q31_negsat),
|
||||
ztest_unit_test(test_arm_sub_q31_possat),
|
||||
ztest_unit_test(test_arm_sub_q31_negsat),
|
||||
ztest_unit_test(test_arm_mult_q31_possat),
|
||||
ztest_unit_test(test_arm_negate_q31_possat),
|
||||
ztest_unit_test(test_arm_offset_q31_possat),
|
||||
ztest_unit_test(test_arm_offset_q31_negsat),
|
||||
ztest_unit_test(test_arm_scale_q31_possat),
|
||||
ztest_unit_test(test_arm_shift_q31_possat),
|
||||
ztest_unit_test(test_arm_shift_q31_negsat),
|
||||
ztest_unit_test(test_arm_and_u32_3),
|
||||
ztest_unit_test(test_arm_and_u32_8),
|
||||
ztest_unit_test(test_arm_and_u32_11),
|
||||
ztest_unit_test(test_arm_or_u32_3),
|
||||
ztest_unit_test(test_arm_or_u32_8),
|
||||
ztest_unit_test(test_arm_or_u32_11),
|
||||
ztest_unit_test(test_arm_not_u32_3),
|
||||
ztest_unit_test(test_arm_not_u32_8),
|
||||
ztest_unit_test(test_arm_not_u32_11),
|
||||
ztest_unit_test(test_arm_xor_u32_3),
|
||||
ztest_unit_test(test_arm_xor_u32_8),
|
||||
ztest_unit_test(test_arm_xor_u32_11),
|
||||
ztest_unit_test(test_arm_add_q31_long),
|
||||
ztest_unit_test(test_arm_sub_q31_long),
|
||||
ztest_unit_test(test_arm_mult_q31_long),
|
||||
ztest_unit_test(test_arm_negate_q31_long),
|
||||
ztest_unit_test(test_arm_offset_q31_long),
|
||||
ztest_unit_test(test_arm_scale_q31_long),
|
||||
ztest_unit_test(test_arm_dot_prod_q31_long),
|
||||
ztest_unit_test(test_arm_abs_q31_long),
|
||||
ztest_unit_test(test_arm_clip_q31_c0000000_f3333333),
|
||||
ztest_unit_test(test_arm_clip_q31_c0000000_40000000),
|
||||
ztest_unit_test(test_arm_clip_q31_0ccccccd_40000000)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(basicmath_q31);
|
||||
}
|
||||
ZTEST_SUITE(basic_math_q31, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
|
@ -42,12 +42,13 @@ static void test_arm_add_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_add_q7, 15, in_com1, in_com2, ref_add, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q7, 32, in_com1, in_com2, ref_add, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q7, 47, in_com1, in_com2, ref_add, 47);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q7, possat, in_maxpos, in_maxpos, ref_add_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q7, negsat, in_maxneg, in_maxneg, ref_add_negsat, 33);
|
||||
DEFINE_TEST_VARIANT4(arm_add_q7, long, in_com1, in_com2, ref_add, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_add_q7, 15, in_com1, in_com2, ref_add, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_add_q7, 32, in_com1, in_com2, ref_add, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_add_q7, 47, in_com1, in_com2, ref_add, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_add_q7, possat, in_maxpos, in_maxpos, ref_add_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_add_q7, negsat, in_maxneg, in_maxneg, ref_add_negsat, 33);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_add_q7, long, in_com1, in_com2, ref_add,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_sub_q7(
|
||||
const q7_t *input1, const q7_t *input2, const q7_t *ref, size_t length)
|
||||
|
@ -74,12 +75,13 @@ static void test_arm_sub_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q7, 15, in_com1, in_com2, ref_sub, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q7, 32, in_com1, in_com2, ref_sub, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q7, 47, in_com1, in_com2, ref_sub, 47);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q7, possat, in_maxpos, in_maxneg, ref_sub_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q7, negsat, in_maxneg, in_maxpos, ref_sub_negsat, 33);
|
||||
DEFINE_TEST_VARIANT4(arm_sub_q7, long, in_com1, in_com2, ref_sub, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_sub_q7, 15, in_com1, in_com2, ref_sub, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_sub_q7, 32, in_com1, in_com2, ref_sub, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_sub_q7, 47, in_com1, in_com2, ref_sub, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_sub_q7, possat, in_maxpos, in_maxneg, ref_sub_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_sub_q7, negsat, in_maxneg, in_maxpos, ref_sub_negsat, 33);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_sub_q7, long, in_com1, in_com2, ref_sub,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_mult_q7(
|
||||
const q7_t *input1, const q7_t *input2, const q7_t *ref, size_t length)
|
||||
|
@ -106,11 +108,13 @@ static void test_arm_mult_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q7, 15, in_com1, in_com2, ref_mult, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q7, 32, in_com1, in_com2, ref_mult, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q7, 47, in_com1, in_com2, ref_mult, 47);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q7, possat, in_maxneg2, in_maxneg2, ref_mult_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(arm_mult_q7, long, in_com1, in_com2, ref_mult, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_mult_q7, 15, in_com1, in_com2, ref_mult, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_mult_q7, 32, in_com1, in_com2, ref_mult, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_mult_q7, 47, in_com1, in_com2, ref_mult, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_mult_q7, possat, in_maxneg2, in_maxneg2, ref_mult_possat,
|
||||
33);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_mult_q7, long, in_com1, in_com2, ref_mult,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_negate_q7(
|
||||
const q7_t *input1, const q7_t *ref, size_t length)
|
||||
|
@ -137,11 +141,11 @@ static void test_arm_negate_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q7, 15, in_com1, ref_negate, 15);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q7, 32, in_com1, ref_negate, 32);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q7, 47, in_com1, ref_negate, 47);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q7, possat, in_maxneg2, ref_negate_possat, 33);
|
||||
DEFINE_TEST_VARIANT3(arm_negate_q7, long, in_com1, ref_negate, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_negate_q7, 15, in_com1, ref_negate, 15);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_negate_q7, 32, in_com1, ref_negate, 32);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_negate_q7, 47, in_com1, ref_negate, 47);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_negate_q7, possat, in_maxneg2, ref_negate_possat, 33);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_negate_q7, long, in_com1, ref_negate, ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_offset_q7(
|
||||
const q7_t *input1, q7_t scalar, const q7_t *ref, size_t length)
|
||||
|
@ -168,12 +172,13 @@ static void test_arm_offset_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q7, 0p5_15, in_com1, 0x40, ref_offset, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q7, 0p5_32, in_com1, 0x40, ref_offset, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q7, 0p5_47, in_com1, 0x40, ref_offset, 47);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q7, possat, in_maxpos, 0x73, ref_offset_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q7, negsat, in_maxneg, 0x8d, ref_offset_negsat, 33);
|
||||
DEFINE_TEST_VARIANT4(arm_offset_q7, long, in_com1, 0x40, ref_offset, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_offset_q7, 0p5_15, in_com1, 0x40, ref_offset, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_offset_q7, 0p5_32, in_com1, 0x40, ref_offset, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_offset_q7, 0p5_47, in_com1, 0x40, ref_offset, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_offset_q7, possat, in_maxpos, 0x73, ref_offset_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_offset_q7, negsat, in_maxneg, 0x8d, ref_offset_negsat, 33);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_offset_q7, long, in_com1, 0x40, ref_offset,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_scale_q7(
|
||||
const q7_t *input1, q7_t scalar, const q7_t *ref, size_t length)
|
||||
|
@ -200,11 +205,12 @@ static void test_arm_scale_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q7, 0p5_15, in_com1, 0x40, ref_scale, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q7, 0p5_32, in_com1, 0x40, ref_scale, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q7, 0p5_47, in_com1, 0x40, ref_scale, 47);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q7, possat, in_maxneg2, 0x80, ref_scale_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(arm_scale_q7, long, in_com1, 0x40, ref_scale, ARRAY_SIZE(in_com1));
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_scale_q7, 0p5_15, in_com1, 0x40, ref_scale, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_scale_q7, 0p5_32, in_com1, 0x40, ref_scale, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_scale_q7, 0p5_47, in_com1, 0x40, ref_scale, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_scale_q7, possat, in_maxneg2, 0x80, ref_scale_possat, 33);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_scale_q7, long, in_com1, 0x40, ref_scale,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_dot_prod_q7(
|
||||
const q7_t *input1, const q7_t *input2, const q31_t *ref,
|
||||
|
@ -232,10 +238,10 @@ static void test_arm_dot_prod_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q7, 15, in_com1, in_com2, ref_dot_prod_3, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q7, 32, in_com1, in_com2, ref_dot_prod_4, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q7, 47, in_com1, in_com2, ref_dot_prod_4n1, 47);
|
||||
DEFINE_TEST_VARIANT4(arm_dot_prod_q7, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_dot_prod_q7, 15, in_com1, in_com2, ref_dot_prod_3, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_dot_prod_q7, 32, in_com1, in_com2, ref_dot_prod_4, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_dot_prod_q7, 47, in_com1, in_com2, ref_dot_prod_4n1, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_dot_prod_q7, long, in_com1, in_com2, ref_dot_prod_long,
|
||||
ARRAY_SIZE(in_com1));
|
||||
|
||||
static void test_arm_abs_q7(
|
||||
|
@ -263,10 +269,10 @@ static void test_arm_abs_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q7, 15, in_com1, ref_abs, 15);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q7, 32, in_com1, ref_abs, 32);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q7, 47, in_com1, ref_abs, 47);
|
||||
DEFINE_TEST_VARIANT3(arm_abs_q7, long, in_com1, ref_abs, ARRAY_SIZE(ref_abs));
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_abs_q7, 15, in_com1, ref_abs, 15);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_abs_q7, 32, in_com1, ref_abs, 32);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_abs_q7, 47, in_com1, ref_abs, 47);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_abs_q7, long, in_com1, ref_abs, ARRAY_SIZE(ref_abs));
|
||||
|
||||
static void test_arm_shift_q7(
|
||||
const q7_t *input1, const q7_t *ref, size_t length)
|
||||
|
@ -293,9 +299,9 @@ static void test_arm_shift_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q7, rand, in_rand, ref_shift, 33);
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q7, possat, in_maxpos, ref_shift_possat, 33);
|
||||
DEFINE_TEST_VARIANT3(arm_shift_q7, negsat, in_maxneg, ref_shift_negsat, 33);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_shift_q7, rand, in_rand, ref_shift, 33);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_shift_q7, possat, in_maxpos, ref_shift_possat, 33);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_shift_q7, negsat, in_maxneg, ref_shift_negsat, 33);
|
||||
|
||||
static void test_arm_and_u8(
|
||||
const uint8_t *input1, const uint8_t *input2, const uint8_t *ref, size_t length)
|
||||
|
@ -318,9 +324,9 @@ static void test_arm_and_u8(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_and_u8, 15, in_bitwise1, in_bitwise2, ref_and, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_and_u8, 32, in_bitwise1, in_bitwise2, ref_and, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_and_u8, 47, in_bitwise1, in_bitwise2, ref_and, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_and_u8, 15, in_bitwise1, in_bitwise2, ref_and, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_and_u8, 32, in_bitwise1, in_bitwise2, ref_and, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_and_u8, 47, in_bitwise1, in_bitwise2, ref_and, 47);
|
||||
|
||||
static void test_arm_or_u8(
|
||||
const uint8_t *input1, const uint8_t *input2, const uint8_t *ref, size_t length)
|
||||
|
@ -343,9 +349,9 @@ static void test_arm_or_u8(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_or_u8, 15, in_bitwise1, in_bitwise2, ref_or, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_or_u8, 32, in_bitwise1, in_bitwise2, ref_or, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_or_u8, 47, in_bitwise1, in_bitwise2, ref_or, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_or_u8, 15, in_bitwise1, in_bitwise2, ref_or, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_or_u8, 32, in_bitwise1, in_bitwise2, ref_or, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_or_u8, 47, in_bitwise1, in_bitwise2, ref_or, 47);
|
||||
|
||||
static void test_arm_not_u8(
|
||||
const uint8_t *input1, const uint8_t *ref, size_t length)
|
||||
|
@ -368,9 +374,9 @@ static void test_arm_not_u8(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_not_u8, 15, in_bitwise1, ref_not, 15);
|
||||
DEFINE_TEST_VARIANT3(arm_not_u8, 32, in_bitwise1, ref_not, 32);
|
||||
DEFINE_TEST_VARIANT3(arm_not_u8, 47, in_bitwise1, ref_not, 47);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_not_u8, 15, in_bitwise1, ref_not, 15);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_not_u8, 32, in_bitwise1, ref_not, 32);
|
||||
DEFINE_TEST_VARIANT3(basic_math_q7, arm_not_u8, 47, in_bitwise1, ref_not, 47);
|
||||
|
||||
static void test_arm_xor_u8(
|
||||
const uint8_t *input1, const uint8_t *input2, const uint8_t *ref, size_t length)
|
||||
|
@ -393,9 +399,9 @@ static void test_arm_xor_u8(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u8, 15, in_bitwise1, in_bitwise2, ref_xor, 15);
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u8, 32, in_bitwise1, in_bitwise2, ref_xor, 32);
|
||||
DEFINE_TEST_VARIANT4(arm_xor_u8, 47, in_bitwise1, in_bitwise2, ref_xor, 47);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_xor_u8, 15, in_bitwise1, in_bitwise2, ref_xor, 15);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_xor_u8, 32, in_bitwise1, in_bitwise2, ref_xor, 32);
|
||||
DEFINE_TEST_VARIANT4(basic_math_q7, arm_xor_u8, 47, in_bitwise1, in_bitwise2, ref_xor, 47);
|
||||
|
||||
static void test_arm_clip_q7(
|
||||
const q7_t *input, const q7_t *ref, q7_t min, q7_t max, size_t length)
|
||||
|
@ -418,73 +424,11 @@ static void test_arm_clip_q7(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q7, c0_f3, in_clip, ref_clip1, 0xc0, 0xf3, ARRAY_SIZE(ref_clip1));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q7, c0_40, in_clip, ref_clip2, 0xc0, 0x40, ARRAY_SIZE(ref_clip2));
|
||||
DEFINE_TEST_VARIANT5(arm_clip_q7, 0d_40, in_clip, ref_clip3, 0x0d, 0x40, ARRAY_SIZE(ref_clip3));
|
||||
DEFINE_TEST_VARIANT5(basic_math_q7, arm_clip_q7, c0_f3, in_clip, ref_clip1, 0xc0, 0xf3,
|
||||
ARRAY_SIZE(ref_clip1));
|
||||
DEFINE_TEST_VARIANT5(basic_math_q7, arm_clip_q7, c0_40, in_clip, ref_clip2, 0xc0, 0x40,
|
||||
ARRAY_SIZE(ref_clip2));
|
||||
DEFINE_TEST_VARIANT5(basic_math_q7, arm_clip_q7, 0d_40, in_clip, ref_clip3, 0x0d, 0x40,
|
||||
ARRAY_SIZE(ref_clip3));
|
||||
|
||||
void test_basicmath_q7(void)
|
||||
{
|
||||
ztest_test_suite(basicmath_q7,
|
||||
ztest_unit_test(test_arm_add_q7_15),
|
||||
ztest_unit_test(test_arm_add_q7_32),
|
||||
ztest_unit_test(test_arm_add_q7_47),
|
||||
ztest_unit_test(test_arm_sub_q7_15),
|
||||
ztest_unit_test(test_arm_sub_q7_32),
|
||||
ztest_unit_test(test_arm_sub_q7_47),
|
||||
ztest_unit_test(test_arm_mult_q7_15),
|
||||
ztest_unit_test(test_arm_mult_q7_32),
|
||||
ztest_unit_test(test_arm_mult_q7_47),
|
||||
ztest_unit_test(test_arm_negate_q7_15),
|
||||
ztest_unit_test(test_arm_negate_q7_32),
|
||||
ztest_unit_test(test_arm_negate_q7_47),
|
||||
ztest_unit_test(test_arm_offset_q7_0p5_15),
|
||||
ztest_unit_test(test_arm_offset_q7_0p5_32),
|
||||
ztest_unit_test(test_arm_offset_q7_0p5_47),
|
||||
ztest_unit_test(test_arm_scale_q7_0p5_15),
|
||||
ztest_unit_test(test_arm_scale_q7_0p5_32),
|
||||
ztest_unit_test(test_arm_scale_q7_0p5_47),
|
||||
ztest_unit_test(test_arm_dot_prod_q7_15),
|
||||
ztest_unit_test(test_arm_dot_prod_q7_32),
|
||||
ztest_unit_test(test_arm_dot_prod_q7_47),
|
||||
ztest_unit_test(test_arm_abs_q7_15),
|
||||
ztest_unit_test(test_arm_abs_q7_32),
|
||||
ztest_unit_test(test_arm_abs_q7_47),
|
||||
ztest_unit_test(test_arm_shift_q7_rand),
|
||||
ztest_unit_test(test_arm_add_q7_possat),
|
||||
ztest_unit_test(test_arm_add_q7_negsat),
|
||||
ztest_unit_test(test_arm_sub_q7_possat),
|
||||
ztest_unit_test(test_arm_sub_q7_negsat),
|
||||
ztest_unit_test(test_arm_mult_q7_possat),
|
||||
ztest_unit_test(test_arm_negate_q7_possat),
|
||||
ztest_unit_test(test_arm_offset_q7_possat),
|
||||
ztest_unit_test(test_arm_offset_q7_negsat),
|
||||
ztest_unit_test(test_arm_scale_q7_possat),
|
||||
ztest_unit_test(test_arm_shift_q7_possat),
|
||||
ztest_unit_test(test_arm_shift_q7_negsat),
|
||||
ztest_unit_test(test_arm_and_u8_15),
|
||||
ztest_unit_test(test_arm_and_u8_32),
|
||||
ztest_unit_test(test_arm_and_u8_47),
|
||||
ztest_unit_test(test_arm_or_u8_15),
|
||||
ztest_unit_test(test_arm_or_u8_32),
|
||||
ztest_unit_test(test_arm_or_u8_47),
|
||||
ztest_unit_test(test_arm_not_u8_15),
|
||||
ztest_unit_test(test_arm_not_u8_32),
|
||||
ztest_unit_test(test_arm_not_u8_47),
|
||||
ztest_unit_test(test_arm_xor_u8_15),
|
||||
ztest_unit_test(test_arm_xor_u8_32),
|
||||
ztest_unit_test(test_arm_xor_u8_47),
|
||||
ztest_unit_test(test_arm_add_q7_long),
|
||||
ztest_unit_test(test_arm_sub_q7_long),
|
||||
ztest_unit_test(test_arm_mult_q7_long),
|
||||
ztest_unit_test(test_arm_negate_q7_long),
|
||||
ztest_unit_test(test_arm_offset_q7_long),
|
||||
ztest_unit_test(test_arm_scale_q7_long),
|
||||
ztest_unit_test(test_arm_dot_prod_q7_long),
|
||||
ztest_unit_test(test_arm_abs_q7_long),
|
||||
ztest_unit_test(test_arm_clip_q7_c0_f3),
|
||||
ztest_unit_test(test_arm_clip_q7_c0_40),
|
||||
ztest_unit_test(test_arm_clip_q7_0d_40)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(basicmath_q7);
|
||||
}
|
||||
ZTEST_SUITE(basic_math_q7, NULL, NULL, NULL, NULL, NULL);
|
||||
|
|
|
@ -6,7 +6,6 @@ project(cmsis_dsp_bayes)
|
|||
|
||||
target_sources(app PRIVATE
|
||||
src/f32.c
|
||||
src/main.c
|
||||
)
|
||||
|
||||
target_sources_ifdef(CONFIG_CMSIS_DSP_FLOAT16 app PRIVATE src/f16.c)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
CONFIG_CMSIS_DSP=y
|
||||
CONFIG_CMSIS_DSP_BAYES=y
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
|
||||
#define REL_ERROR_THRESH (3.0e-3)
|
||||
|
||||
void test_gaussian_naive_bayes_predict_f16(void)
|
||||
/* Note: this source file is only built when CONFIG_CMSIS_DSP_FLOAT16 is enabled */
|
||||
|
||||
ZTEST_SUITE(bayes_f16, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ZTEST(bayes_f16, test_gaussian_naive_bayes_predict_f16)
|
||||
{
|
||||
arm_gaussian_naive_bayes_instance_f16 inst;
|
||||
|
||||
|
@ -80,12 +84,3 @@ void test_gaussian_naive_bayes_predict_f16(void)
|
|||
free(output_probs_buf);
|
||||
free(output_preds_buf);
|
||||
}
|
||||
|
||||
void test_bayes_f16(void)
|
||||
{
|
||||
ztest_test_suite(bayes_f16,
|
||||
ztest_unit_test(test_gaussian_naive_bayes_predict_f16)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(bayes_f16);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
|
||||
#define REL_ERROR_THRESH (5.0e-6)
|
||||
|
||||
void test_gaussian_naive_bayes_predict_f32(void)
|
||||
ZTEST_SUITE(bayes_f32, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ZTEST(bayes_f32, test_gaussian_naive_bayes_predict_f16)
|
||||
{
|
||||
arm_gaussian_naive_bayes_instance_f32 inst;
|
||||
|
||||
|
@ -80,12 +82,3 @@ void test_gaussian_naive_bayes_predict_f32(void)
|
|||
free(output_probs_buf);
|
||||
free(output_preds_buf);
|
||||
}
|
||||
|
||||
void test_bayes_f32(void)
|
||||
{
|
||||
ztest_test_suite(bayes_f32,
|
||||
ztest_unit_test(test_gaussian_naive_bayes_predict_f32)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(bayes_f32);
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Stephanos Ioannidis <root@stephanos.io>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <zephyr.h>
|
||||
|
||||
extern void test_bayes_f16(void);
|
||||
extern void test_bayes_f32(void);
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
#ifdef CONFIG_CMSIS_DSP_FLOAT16
|
||||
test_bayes_f16();
|
||||
#endif
|
||||
test_bayes_f32();
|
||||
}
|
|
@ -26,6 +26,49 @@
|
|||
#define ASSERT_MSG_ERROR_LIMIT_EXCEED "error limit exceeded"
|
||||
#define ASSERT_MSG_INCORRECT_COMP_RESULT "incorrect computation result"
|
||||
|
||||
#if defined(CONFIG_ZTEST_NEW_API)
|
||||
#define DEFINE_TEST_VARIANT1(suite, name, variant, a1) \
|
||||
ZTEST(suite, test_##name##_##variant) \
|
||||
{ \
|
||||
test_##name(a1); \
|
||||
}
|
||||
|
||||
#define DEFINE_TEST_VARIANT2(suite, name, variant, a1, a2) \
|
||||
ZTEST(suite, test_##name##_##variant) \
|
||||
{ \
|
||||
test_##name(a1, a2); \
|
||||
}
|
||||
|
||||
#define DEFINE_TEST_VARIANT3(suite, name, variant, a1, a2, a3) \
|
||||
ZTEST(suite, test_##name##_##variant) \
|
||||
{ \
|
||||
test_##name(a1, a2, a3); \
|
||||
}
|
||||
|
||||
#define DEFINE_TEST_VARIANT4(suite, name, variant, a1, a2, a3, a4) \
|
||||
ZTEST(suite, test_##name##_##variant) \
|
||||
{ \
|
||||
test_##name(a1, a2, a3, a4); \
|
||||
}
|
||||
|
||||
#define DEFINE_TEST_VARIANT5(suite, name, variant, a1, a2, a3, a4, a5) \
|
||||
ZTEST(suite, test_##name##_##variant) \
|
||||
{ \
|
||||
test_##name(a1, a2, a3, a4, a5); \
|
||||
}
|
||||
|
||||
#define DEFINE_TEST_VARIANT6(suite, name, variant, a1, a2, a3, a4, a5, a6) \
|
||||
ZTEST(suite, test_##name##_##variant) \
|
||||
{ \
|
||||
test_##name(a1, a2, a3, a4, a5, a6); \
|
||||
}
|
||||
|
||||
#define DEFINE_TEST_VARIANT7(suite, name, variant, a1, a2, a3, a4, a5, a6, a7) \
|
||||
ZTEST(suite, test_##name##_##variant) \
|
||||
{ \
|
||||
test_##name(a1, a2, a3, a4, a5, a6, a7); \
|
||||
}
|
||||
#else /* !defined(CONFIG_ZTEST_NEW_API) */
|
||||
#define DEFINE_TEST_VARIANT1(name, variant, a1) \
|
||||
static void test_##name##_##variant(void) \
|
||||
{ \
|
||||
|
@ -67,6 +110,7 @@
|
|||
{ \
|
||||
test_##name(a1, a2, a3, a4, a5, a6, a7); \
|
||||
}
|
||||
#endif /* !defined(CONFIG_ZTEST_NEW_API) */
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||
|
|
|
@ -8,7 +8,6 @@ target_sources(app PRIVATE
|
|||
src/q15.c
|
||||
src/q31.c
|
||||
src/f32.c
|
||||
src/main.c
|
||||
)
|
||||
|
||||
target_sources_ifdef(CONFIG_CMSIS_DSP_FLOAT16 app PRIVATE src/f16.c)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
CONFIG_CMSIS_DSP=y
|
||||
CONFIG_CMSIS_DSP_COMPLEXMATH=y
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#define SNR_ERROR_THRESH ((float32_t)39)
|
||||
#define REL_ERROR_THRESH (6.0e-2)
|
||||
|
||||
ZTEST_SUITE(complexmath_f16, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
static void test_arm_cmplx_conj_f16(
|
||||
const uint16_t *input1, const uint16_t *ref, size_t length)
|
||||
{
|
||||
|
@ -47,9 +49,9 @@ static void test_arm_cmplx_conj_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_f16, 7, in_com1, ref_conj, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_f16, 16, in_com1, ref_conj, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_f16, 23, in_com1, ref_conj, 23);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_conj_f16, 7, in_com1, ref_conj, 7);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_conj_f16, 16, in_com1, ref_conj, 16);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_conj_f16, 23, in_com1, ref_conj, 23);
|
||||
|
||||
static void test_arm_cmplx_dot_prod_f16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -81,9 +83,12 @@ static void test_arm_cmplx_dot_prod_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_f16, 7, in_com1, in_com2, ref_dot_prod_3, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_f16, 16, in_com1, in_com2, ref_dot_prod_4n, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_f16, 23, in_com1, in_com2, ref_dot_prod_4n1, 23);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_dot_prod_f16, 7, in_com1, in_com2, ref_dot_prod_3,
|
||||
7);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_dot_prod_f16, 16, in_com1, in_com2, ref_dot_prod_4n,
|
||||
16);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_dot_prod_f16, 23, in_com1, in_com2,
|
||||
ref_dot_prod_4n1, 23);
|
||||
|
||||
static void test_arm_cmplx_mag_f16(
|
||||
const uint16_t *input1, const uint16_t *ref, size_t length)
|
||||
|
@ -112,9 +117,9 @@ static void test_arm_cmplx_mag_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_f16, 7, in_com1, ref_mag, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_f16, 16, in_com1, ref_mag, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_f16, 23, in_com1, ref_mag, 23);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_mag_f16, 7, in_com1, ref_mag, 7);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_mag_f16, 16, in_com1, ref_mag, 16);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_mag_f16, 23, in_com1, ref_mag, 23);
|
||||
|
||||
static void test_arm_cmplx_mag_squared_f16(
|
||||
const uint16_t *input1, const uint16_t *ref, size_t length)
|
||||
|
@ -143,9 +148,9 @@ static void test_arm_cmplx_mag_squared_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_f16, 7, in_com1, ref_mag_squared, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_f16, 16, in_com1, ref_mag_squared, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_f16, 23, in_com1, ref_mag_squared, 23);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_mag_squared_f16, 7, in_com1, ref_mag_squared, 7);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_mag_squared_f16, 16, in_com1, ref_mag_squared, 16);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f16, arm_cmplx_mag_squared_f16, 23, in_com1, ref_mag_squared, 23);
|
||||
|
||||
static void test_arm_cmplx_mult_cmplx_f16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -180,9 +185,12 @@ static void test_arm_cmplx_mult_cmplx_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_f16, 7, in_com1, in_com2, ref_mult_cmplx, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_f16, 16, in_com1, in_com2, ref_mult_cmplx, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_f16, 23, in_com1, in_com2, ref_mult_cmplx, 23);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_mult_cmplx_f16, 7, in_com1, in_com2, ref_mult_cmplx,
|
||||
7);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_mult_cmplx_f16, 16, in_com1, in_com2,
|
||||
ref_mult_cmplx, 16);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_mult_cmplx_f16, 23, in_com1, in_com2,
|
||||
ref_mult_cmplx, 23);
|
||||
|
||||
static void test_arm_cmplx_mult_real_f16(
|
||||
const uint16_t *input1, const uint16_t *input2, const uint16_t *ref,
|
||||
|
@ -219,32 +227,9 @@ static void test_arm_cmplx_mult_real_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_f16, 7, in_com1, in_com3, ref_mult_real, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_f16, 16, in_com1, in_com3, ref_mult_real, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_f16, 23, in_com1, in_com3, ref_mult_real, 23);
|
||||
|
||||
void test_complexmath_f16(void)
|
||||
{
|
||||
ztest_test_suite(complexmath_f16,
|
||||
ztest_unit_test(test_arm_cmplx_conj_f16_7),
|
||||
ztest_unit_test(test_arm_cmplx_conj_f16_16),
|
||||
ztest_unit_test(test_arm_cmplx_conj_f16_23),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_f16_7),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_f16_16),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_f16_23),
|
||||
ztest_unit_test(test_arm_cmplx_mag_f16_7),
|
||||
ztest_unit_test(test_arm_cmplx_mag_f16_16),
|
||||
ztest_unit_test(test_arm_cmplx_mag_f16_23),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_f16_7),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_f16_16),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_f16_23),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_f16_7),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_f16_16),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_f16_23),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_f16_7),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_f16_16),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_f16_23)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(complexmath_f16);
|
||||
}
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_mult_real_f16, 7, in_com1, in_com3, ref_mult_real,
|
||||
7);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_mult_real_f16, 16, in_com1, in_com3, ref_mult_real,
|
||||
16);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f16, arm_cmplx_mult_real_f16, 23, in_com1, in_com3, ref_mult_real,
|
||||
23);
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
#define SNR_ERROR_THRESH ((float32_t)120)
|
||||
#define REL_ERROR_THRESH (7.0e-6)
|
||||
|
||||
ZTEST_SUITE(complexmath_f32, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
static void test_arm_cmplx_conj_f32(
|
||||
const uint32_t *input1, const uint32_t *ref, size_t length)
|
||||
{
|
||||
|
@ -47,9 +49,9 @@ static void test_arm_cmplx_conj_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_f32, 3, in_com1, ref_conj, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_f32, 8, in_com1, ref_conj, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_f32, 11, in_com1, ref_conj, 11);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_conj_f32, 3, in_com1, ref_conj, 3);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_conj_f32, 8, in_com1, ref_conj, 8);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_conj_f32, 11, in_com1, ref_conj, 11);
|
||||
|
||||
static void test_arm_cmplx_dot_prod_f32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref,
|
||||
|
@ -81,9 +83,12 @@ static void test_arm_cmplx_dot_prod_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_f32, 3, in_com1, in_com2, ref_dot_prod_3, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_f32, 8, in_com1, in_com2, ref_dot_prod_4n, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_f32, 11, in_com1, in_com2, ref_dot_prod_4n1, 11);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_dot_prod_f32, 3, in_com1, in_com2, ref_dot_prod_3,
|
||||
3);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_dot_prod_f32, 8, in_com1, in_com2, ref_dot_prod_4n,
|
||||
8);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_dot_prod_f32, 11, in_com1, in_com2,
|
||||
ref_dot_prod_4n1, 11);
|
||||
|
||||
static void test_arm_cmplx_mag_f32(
|
||||
const uint32_t *input1, const uint32_t *ref, size_t length)
|
||||
|
@ -112,9 +117,9 @@ static void test_arm_cmplx_mag_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_f32, 3, in_com1, ref_mag, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_f32, 8, in_com1, ref_mag, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_f32, 11, in_com1, ref_mag, 11);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_mag_f32, 3, in_com1, ref_mag, 3);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_mag_f32, 8, in_com1, ref_mag, 8);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_mag_f32, 11, in_com1, ref_mag, 11);
|
||||
|
||||
static void test_arm_cmplx_mag_squared_f32(
|
||||
const uint32_t *input1, const uint32_t *ref, size_t length)
|
||||
|
@ -143,9 +148,9 @@ static void test_arm_cmplx_mag_squared_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_f32, 3, in_com1, ref_mag_squared, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_f32, 8, in_com1, ref_mag_squared, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_f32, 11, in_com1, ref_mag_squared, 11);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_mag_squared_f32, 3, in_com1, ref_mag_squared, 3);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_mag_squared_f32, 8, in_com1, ref_mag_squared, 8);
|
||||
DEFINE_TEST_VARIANT3(complexmath_f32, arm_cmplx_mag_squared_f32, 11, in_com1, ref_mag_squared, 11);
|
||||
|
||||
static void test_arm_cmplx_mult_cmplx_f32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref,
|
||||
|
@ -180,9 +185,12 @@ static void test_arm_cmplx_mult_cmplx_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_f32, 3, in_com1, in_com2, ref_mult_cmplx, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_f32, 8, in_com1, in_com2, ref_mult_cmplx, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_f32, 11, in_com1, in_com2, ref_mult_cmplx, 11);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_mult_cmplx_f32, 3, in_com1, in_com2, ref_mult_cmplx,
|
||||
3);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_mult_cmplx_f32, 8, in_com1, in_com2, ref_mult_cmplx,
|
||||
8);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_mult_cmplx_f32, 11, in_com1, in_com2,
|
||||
ref_mult_cmplx, 11);
|
||||
|
||||
static void test_arm_cmplx_mult_real_f32(
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref,
|
||||
|
@ -219,32 +227,9 @@ static void test_arm_cmplx_mult_real_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_f32, 3, in_com1, in_com3, ref_mult_real, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_f32, 8, in_com1, in_com3, ref_mult_real, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_f32, 11, in_com1, in_com3, ref_mult_real, 11);
|
||||
|
||||
void test_complexmath_f32(void)
|
||||
{
|
||||
ztest_test_suite(complexmath_f32,
|
||||
ztest_unit_test(test_arm_cmplx_conj_f32_3),
|
||||
ztest_unit_test(test_arm_cmplx_conj_f32_8),
|
||||
ztest_unit_test(test_arm_cmplx_conj_f32_11),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_f32_3),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_f32_8),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_f32_11),
|
||||
ztest_unit_test(test_arm_cmplx_mag_f32_3),
|
||||
ztest_unit_test(test_arm_cmplx_mag_f32_8),
|
||||
ztest_unit_test(test_arm_cmplx_mag_f32_11),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_f32_3),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_f32_8),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_f32_11),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_f32_3),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_f32_8),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_f32_11),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_f32_3),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_f32_8),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_f32_11)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(complexmath_f32);
|
||||
}
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_mult_real_f32, 3, in_com1, in_com3, ref_mult_real,
|
||||
3);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_mult_real_f32, 8, in_com1, in_com3, ref_mult_real,
|
||||
8);
|
||||
DEFINE_TEST_VARIANT4(complexmath_f32, arm_cmplx_mult_real_f32, 11, in_com1, in_com3, ref_mult_real,
|
||||
11);
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Stephanos Ioannidis <root@stephanos.io>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <zephyr.h>
|
||||
|
||||
extern void test_complexmath_q15(void);
|
||||
extern void test_complexmath_q31(void);
|
||||
extern void test_complexmath_f16(void);
|
||||
extern void test_complexmath_f32(void);
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
test_complexmath_q15();
|
||||
test_complexmath_q31();
|
||||
#ifdef CONFIG_CMSIS_DSP_FLOAT16
|
||||
test_complexmath_f16();
|
||||
#endif
|
||||
test_complexmath_f32();
|
||||
}
|
|
@ -18,6 +18,8 @@
|
|||
#define ABS_ERROR_THRESH_Q15 ((q15_t)50)
|
||||
#define ABS_ERROR_THRESH_Q31 ((q31_t)(1 << 15))
|
||||
|
||||
ZTEST_SUITE(complexmath_q15, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
static void test_arm_cmplx_conj_q15(
|
||||
const q15_t *input1, const q15_t *ref, size_t length)
|
||||
{
|
||||
|
@ -48,9 +50,9 @@ static void test_arm_cmplx_conj_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_q15, 7, in_com1, ref_conj, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_q15, 16, in_com1, ref_conj, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_q15, 23, in_com1, ref_conj, 23);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_conj_q15, 7, in_com1, ref_conj, 7);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_conj_q15, 16, in_com1, ref_conj, 16);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_conj_q15, 23, in_com1, ref_conj, 23);
|
||||
|
||||
static void test_arm_cmplx_dot_prod_q15(
|
||||
const q15_t *input1, const q15_t *input2, const q31_t *ref,
|
||||
|
@ -78,9 +80,12 @@ static void test_arm_cmplx_dot_prod_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_q15, 7, in_com1, in_com2, ref_dot_prod_3, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_q15, 16, in_com1, in_com2, ref_dot_prod_4n, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_q15, 23, in_com1, in_com2, ref_dot_prod_4n1, 23);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_dot_prod_q15, 7, in_com1, in_com2, ref_dot_prod_3,
|
||||
7);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_dot_prod_q15, 16, in_com1, in_com2, ref_dot_prod_4n,
|
||||
16);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_dot_prod_q15, 23, in_com1, in_com2,
|
||||
ref_dot_prod_4n1, 23);
|
||||
|
||||
static void test_arm_cmplx_mag_q15(
|
||||
const q15_t *input1, const q15_t *ref, size_t length)
|
||||
|
@ -107,9 +112,9 @@ static void test_arm_cmplx_mag_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_q15, 7, in_com1, ref_mag, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_q15, 16, in_com1, ref_mag, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_q15, 23, in_com1, ref_mag, 23);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_mag_q15, 7, in_com1, ref_mag, 7);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_mag_q15, 16, in_com1, ref_mag, 16);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_mag_q15, 23, in_com1, ref_mag, 23);
|
||||
|
||||
static void test_arm_cmplx_mag_squared_q15(
|
||||
const q15_t *input1, const q15_t *ref, size_t length)
|
||||
|
@ -136,9 +141,9 @@ static void test_arm_cmplx_mag_squared_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_q15, 7, in_com1, ref_mag_squared, 7);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_q15, 16, in_com1, ref_mag_squared, 16);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_q15, 23, in_com1, ref_mag_squared, 23);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_mag_squared_q15, 7, in_com1, ref_mag_squared, 7);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_mag_squared_q15, 16, in_com1, ref_mag_squared, 16);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q15, arm_cmplx_mag_squared_q15, 23, in_com1, ref_mag_squared, 23);
|
||||
|
||||
static void test_arm_cmplx_mult_cmplx_q15(
|
||||
const q15_t *input1, const q15_t *input2, const q15_t *ref,
|
||||
|
@ -171,9 +176,12 @@ static void test_arm_cmplx_mult_cmplx_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_q15, 7, in_com1, in_com2, ref_mult_cmplx, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_q15, 16, in_com1, in_com2, ref_mult_cmplx, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_q15, 23, in_com1, in_com2, ref_mult_cmplx, 23);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_mult_cmplx_q15, 7, in_com1, in_com2, ref_mult_cmplx,
|
||||
7);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_mult_cmplx_q15, 16, in_com1, in_com2,
|
||||
ref_mult_cmplx, 16);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_mult_cmplx_q15, 23, in_com1, in_com2,
|
||||
ref_mult_cmplx, 23);
|
||||
|
||||
static void test_arm_cmplx_mult_real_q15(
|
||||
const q15_t *input1, const q15_t *input2, const q15_t *ref,
|
||||
|
@ -206,32 +214,9 @@ static void test_arm_cmplx_mult_real_q15(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_q15, 7, in_com1, in_com3, ref_mult_real, 7);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_q15, 16, in_com1, in_com3, ref_mult_real, 16);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_q15, 23, in_com1, in_com3, ref_mult_real, 23);
|
||||
|
||||
void test_complexmath_q15(void)
|
||||
{
|
||||
ztest_test_suite(complexmath_q15,
|
||||
ztest_unit_test(test_arm_cmplx_conj_q15_7),
|
||||
ztest_unit_test(test_arm_cmplx_conj_q15_16),
|
||||
ztest_unit_test(test_arm_cmplx_conj_q15_23),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_q15_7),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_q15_16),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_q15_23),
|
||||
ztest_unit_test(test_arm_cmplx_mag_q15_7),
|
||||
ztest_unit_test(test_arm_cmplx_mag_q15_16),
|
||||
ztest_unit_test(test_arm_cmplx_mag_q15_23),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_q15_7),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_q15_16),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_q15_23),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_q15_7),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_q15_16),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_q15_23),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_q15_7),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_q15_16),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_q15_23)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(complexmath_q15);
|
||||
}
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_mult_real_q15, 7, in_com1, in_com3, ref_mult_real,
|
||||
7);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_mult_real_q15, 16, in_com1, in_com3, ref_mult_real,
|
||||
16);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q15, arm_cmplx_mult_real_q15, 23, in_com1, in_com3, ref_mult_real,
|
||||
23);
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
#define ABS_ERROR_THRESH_Q31 ((q31_t)100)
|
||||
#define ABS_ERROR_THRESH_Q63 ((q63_t)(1 << 18))
|
||||
|
||||
ZTEST_SUITE(complexmath_q31, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
static void test_arm_cmplx_conj_q31(
|
||||
const q31_t *input1, const q31_t *ref, size_t length)
|
||||
{
|
||||
|
@ -47,9 +49,9 @@ static void test_arm_cmplx_conj_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_q31, 3, in_com1, ref_conj, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_q31, 8, in_com1, ref_conj, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_conj_q31, 11, in_com1, ref_conj, 11);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_conj_q31, 3, in_com1, ref_conj, 3);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_conj_q31, 8, in_com1, ref_conj, 8);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_conj_q31, 11, in_com1, ref_conj, 11);
|
||||
|
||||
static void test_arm_cmplx_dot_prod_q31(
|
||||
const q31_t *input1, const q31_t *input2, const q63_t *ref,
|
||||
|
@ -77,9 +79,12 @@ static void test_arm_cmplx_dot_prod_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_q31, 3, in_com1, in_com2, ref_dot_prod_3, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_q31, 8, in_com1, in_com2, ref_dot_prod_4n, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_dot_prod_q31, 11, in_com1, in_com2, ref_dot_prod_4n1, 11);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_dot_prod_q31, 3, in_com1, in_com2, ref_dot_prod_3,
|
||||
3);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_dot_prod_q31, 8, in_com1, in_com2, ref_dot_prod_4n,
|
||||
8);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_dot_prod_q31, 11, in_com1, in_com2,
|
||||
ref_dot_prod_4n1, 11);
|
||||
|
||||
static void test_arm_cmplx_mag_q31(
|
||||
const q31_t *input1, const q31_t *ref, size_t length)
|
||||
|
@ -106,9 +111,9 @@ static void test_arm_cmplx_mag_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_q31, 3, in_com1, ref_mag, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_q31, 8, in_com1, ref_mag, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_q31, 11, in_com1, ref_mag, 11);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_mag_q31, 3, in_com1, ref_mag, 3);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_mag_q31, 8, in_com1, ref_mag, 8);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_mag_q31, 11, in_com1, ref_mag, 11);
|
||||
|
||||
static void test_arm_cmplx_mag_squared_q31(
|
||||
const q31_t *input1, const q31_t *ref, size_t length)
|
||||
|
@ -135,9 +140,9 @@ static void test_arm_cmplx_mag_squared_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_q31, 3, in_com1, ref_mag_squared, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_q31, 8, in_com1, ref_mag_squared, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_cmplx_mag_squared_q31, 11, in_com1, ref_mag_squared, 11);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_mag_squared_q31, 3, in_com1, ref_mag_squared, 3);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_mag_squared_q31, 8, in_com1, ref_mag_squared, 8);
|
||||
DEFINE_TEST_VARIANT3(complexmath_q31, arm_cmplx_mag_squared_q31, 11, in_com1, ref_mag_squared, 11);
|
||||
|
||||
static void test_arm_cmplx_mult_cmplx_q31(
|
||||
const q31_t *input1, const q31_t *input2, const q31_t *ref,
|
||||
|
@ -170,9 +175,12 @@ static void test_arm_cmplx_mult_cmplx_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_q31, 3, in_com1, in_com2, ref_mult_cmplx, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_q31, 8, in_com1, in_com2, ref_mult_cmplx, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_cmplx_q31, 11, in_com1, in_com2, ref_mult_cmplx, 11);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_mult_cmplx_q31, 3, in_com1, in_com2, ref_mult_cmplx,
|
||||
3);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_mult_cmplx_q31, 8, in_com1, in_com2, ref_mult_cmplx,
|
||||
8);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_mult_cmplx_q31, 11, in_com1, in_com2,
|
||||
ref_mult_cmplx, 11);
|
||||
|
||||
static void test_arm_cmplx_mult_real_q31(
|
||||
const q31_t *input1, const q31_t *input2, const q31_t *ref,
|
||||
|
@ -205,32 +213,9 @@ static void test_arm_cmplx_mult_real_q31(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_q31, 3, in_com1, in_com3, ref_mult_real, 3);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_q31, 8, in_com1, in_com3, ref_mult_real, 8);
|
||||
DEFINE_TEST_VARIANT4(arm_cmplx_mult_real_q31, 11, in_com1, in_com3, ref_mult_real, 11);
|
||||
|
||||
void test_complexmath_q31(void)
|
||||
{
|
||||
ztest_test_suite(complexmath_q31,
|
||||
ztest_unit_test(test_arm_cmplx_conj_q31_3),
|
||||
ztest_unit_test(test_arm_cmplx_conj_q31_8),
|
||||
ztest_unit_test(test_arm_cmplx_conj_q31_11),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_q31_3),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_q31_8),
|
||||
ztest_unit_test(test_arm_cmplx_dot_prod_q31_11),
|
||||
ztest_unit_test(test_arm_cmplx_mag_q31_3),
|
||||
ztest_unit_test(test_arm_cmplx_mag_q31_8),
|
||||
ztest_unit_test(test_arm_cmplx_mag_q31_11),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_q31_3),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_q31_8),
|
||||
ztest_unit_test(test_arm_cmplx_mag_squared_q31_11),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_q31_3),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_q31_8),
|
||||
ztest_unit_test(test_arm_cmplx_mult_cmplx_q31_11),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_q31_3),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_q31_8),
|
||||
ztest_unit_test(test_arm_cmplx_mult_real_q31_11)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(complexmath_q31);
|
||||
}
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_mult_real_q31, 3, in_com1, in_com3, ref_mult_real,
|
||||
3);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_mult_real_q31, 8, in_com1, in_com3, ref_mult_real,
|
||||
8);
|
||||
DEFINE_TEST_VARIANT4(complexmath_q31, arm_cmplx_mult_real_q31, 11, in_com1, in_com3, ref_mult_real,
|
||||
11);
|
||||
|
|
|
@ -7,7 +7,6 @@ project(cmsis_dsp_distance)
|
|||
target_sources(app PRIVATE
|
||||
src/u32.c
|
||||
src/f32.c
|
||||
src/main.c
|
||||
)
|
||||
|
||||
target_sources_ifdef(CONFIG_CMSIS_DSP_FLOAT16 app PRIVATE src/f16.c)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
CONFIG_CMSIS_DSP=y
|
||||
CONFIG_CMSIS_DSP_DISTANCE=y
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#define OP_JENSENSHANNON (7)
|
||||
#define OP_MINKOWSKI (8)
|
||||
|
||||
ZTEST_SUITE(distance_f16, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
static void test_arm_distance(int op, bool scratchy, const uint16_t *dims,
|
||||
const uint16_t *dinput1, const uint16_t *dinput2, const uint16_t *ref)
|
||||
{
|
||||
|
@ -132,39 +134,39 @@ static void test_arm_distance(int op, bool scratchy, const uint16_t *dims,
|
|||
free(tmp2);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f16,
|
||||
arm_distance, braycurtis, OP_BRAYCURTIS, false, in_dims,
|
||||
in_com1, in_com2, ref_braycurtis);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f16,
|
||||
arm_distance, canberra, OP_CANBERRA, false, in_dims,
|
||||
in_com1, in_com2, ref_canberra);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f16,
|
||||
arm_distance, chebyshev, OP_CHEBYSHEV, false, in_dims,
|
||||
in_com1, in_com2, ref_chebyshev);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f16,
|
||||
arm_distance, cityblock, OP_CITYBLOCK, false, in_dims,
|
||||
in_com1, in_com2, ref_cityblock);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f16,
|
||||
arm_distance, correlation, OP_CORRELATION, true, in_dims,
|
||||
in_com1, in_com2, ref_correlation);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f16,
|
||||
arm_distance, cosine, OP_COSINE, false, in_dims,
|
||||
in_com1, in_com2, ref_cosine);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f16,
|
||||
arm_distance, euclidean, OP_EUCLIDEAN, false, in_dims,
|
||||
in_com1, in_com2, ref_euclidean);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f16,
|
||||
arm_distance, jensenshannon, OP_JENSENSHANNON, false, in_dims,
|
||||
in_jen1, in_jen2, ref_jensenshannon);
|
||||
|
||||
static void test_arm_distance_minkowski(void)
|
||||
ZTEST(distance_f16, test_arm_distance_minkowski)
|
||||
{
|
||||
size_t index;
|
||||
const size_t length = in_dims_minkowski[0];
|
||||
|
@ -199,20 +201,3 @@ static void test_arm_distance_minkowski(void)
|
|||
/* Free buffers */
|
||||
free(output);
|
||||
}
|
||||
|
||||
void test_distance_f16(void)
|
||||
{
|
||||
ztest_test_suite(distance_f16,
|
||||
ztest_unit_test(test_arm_distance_braycurtis),
|
||||
ztest_unit_test(test_arm_distance_canberra),
|
||||
ztest_unit_test(test_arm_distance_chebyshev),
|
||||
ztest_unit_test(test_arm_distance_cityblock),
|
||||
ztest_unit_test(test_arm_distance_correlation),
|
||||
ztest_unit_test(test_arm_distance_cosine),
|
||||
ztest_unit_test(test_arm_distance_euclidean),
|
||||
ztest_unit_test(test_arm_distance_jensenshannon),
|
||||
ztest_unit_test(test_arm_distance_minkowski)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(distance_f16);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
#define OP_JENSENSHANNON (7)
|
||||
#define OP_MINKOWSKI (8)
|
||||
|
||||
ZTEST_SUITE(distance_f32, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
static void test_arm_distance(int op, bool scratchy, const uint16_t *dims,
|
||||
const uint32_t *dinput1, const uint32_t *dinput2, const uint32_t *ref)
|
||||
{
|
||||
|
@ -118,39 +120,39 @@ static void test_arm_distance(int op, bool scratchy, const uint16_t *dims,
|
|||
free(tmp2);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f32,
|
||||
arm_distance, braycurtis, OP_BRAYCURTIS, false, in_dims,
|
||||
in_com1, in_com2, ref_braycurtis);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f32,
|
||||
arm_distance, canberra, OP_CANBERRA, false, in_dims,
|
||||
in_com1, in_com2, ref_canberra);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f32,
|
||||
arm_distance, chebyshev, OP_CHEBYSHEV, false, in_dims,
|
||||
in_com1, in_com2, ref_chebyshev);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f32,
|
||||
arm_distance, cityblock, OP_CITYBLOCK, false, in_dims,
|
||||
in_com1, in_com2, ref_cityblock);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f32,
|
||||
arm_distance, correlation, OP_CORRELATION, true, in_dims,
|
||||
in_com1, in_com2, ref_correlation);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f32,
|
||||
arm_distance, cosine, OP_COSINE, false, in_dims,
|
||||
in_com1, in_com2, ref_cosine);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f32,
|
||||
arm_distance, euclidean, OP_EUCLIDEAN, false, in_dims,
|
||||
in_com1, in_com2, ref_euclidean);
|
||||
|
||||
DEFINE_TEST_VARIANT6(
|
||||
DEFINE_TEST_VARIANT6(distance_f32,
|
||||
arm_distance, jensenshannon, OP_JENSENSHANNON, false, in_dims,
|
||||
in_jen1, in_jen2, ref_jensenshannon);
|
||||
|
||||
static void test_arm_distance_minkowski(void)
|
||||
ZTEST(distance_f32, test_arm_distance_minkowski)
|
||||
{
|
||||
size_t index;
|
||||
const size_t length = in_dims_minkowski[0];
|
||||
|
@ -185,20 +187,3 @@ static void test_arm_distance_minkowski(void)
|
|||
/* Free buffers */
|
||||
free(output);
|
||||
}
|
||||
|
||||
void test_distance_f32(void)
|
||||
{
|
||||
ztest_test_suite(distance_f32,
|
||||
ztest_unit_test(test_arm_distance_braycurtis),
|
||||
ztest_unit_test(test_arm_distance_canberra),
|
||||
ztest_unit_test(test_arm_distance_chebyshev),
|
||||
ztest_unit_test(test_arm_distance_cityblock),
|
||||
ztest_unit_test(test_arm_distance_correlation),
|
||||
ztest_unit_test(test_arm_distance_cosine),
|
||||
ztest_unit_test(test_arm_distance_euclidean),
|
||||
ztest_unit_test(test_arm_distance_jensenshannon),
|
||||
ztest_unit_test(test_arm_distance_minkowski)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(distance_f32);
|
||||
}
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Stephanos Ioannidis <root@stephanos.io>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <zephyr.h>
|
||||
|
||||
extern void test_distance_u32(void);
|
||||
extern void test_distance_f16(void);
|
||||
extern void test_distance_f32(void);
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
test_distance_u32();
|
||||
#ifdef CONFIG_CMSIS_DSP_FLOAT16
|
||||
test_distance_f16();
|
||||
#endif
|
||||
test_distance_f32();
|
||||
}
|
|
@ -29,6 +29,8 @@
|
|||
#define OP_SOKALSNEATH (7)
|
||||
#define OP_YULE (8)
|
||||
|
||||
ZTEST_SUITE(distance_u32, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
static void test_arm_distance(int op, const uint16_t *dims,
|
||||
const uint32_t *input1, const uint32_t *input2, const uint32_t *ref)
|
||||
{
|
||||
|
@ -99,55 +101,38 @@ static void test_arm_distance(int op, const uint16_t *dims,
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, dice, OP_DICE, in_dims,
|
||||
in_com1, in_com2, ref_dice);
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, hamming, OP_HAMMING, in_dims,
|
||||
in_com1, in_com2, ref_hamming);
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, jaccard, OP_JACCARD, in_dims,
|
||||
in_com1, in_com2, ref_jaccard);
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, kulsinski, OP_KULSINSKI, in_dims,
|
||||
in_com1, in_com2, ref_kulsinski);
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, rogerstanimoto, OP_ROGERSTANIMOTO, in_dims,
|
||||
in_com1, in_com2, ref_rogerstanimoto);
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, russellrao, OP_RUSSELLRAO, in_dims,
|
||||
in_com1, in_com2, ref_russellrao);
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, sokalmichener, OP_SOKALMICHENER, in_dims,
|
||||
in_com1, in_com2, ref_sokalmichener);
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, sokalsneath, OP_SOKALSNEATH, in_dims,
|
||||
in_com1, in_com2, ref_sokalsneath);
|
||||
|
||||
DEFINE_TEST_VARIANT5(
|
||||
DEFINE_TEST_VARIANT5(distance_u32,
|
||||
arm_distance, yule, OP_YULE, in_dims,
|
||||
in_com1, in_com2, ref_yule);
|
||||
|
||||
void test_distance_u32(void)
|
||||
{
|
||||
ztest_test_suite(distance_u32,
|
||||
ztest_unit_test(test_arm_distance_dice),
|
||||
ztest_unit_test(test_arm_distance_hamming),
|
||||
ztest_unit_test(test_arm_distance_jaccard),
|
||||
ztest_unit_test(test_arm_distance_kulsinski),
|
||||
ztest_unit_test(test_arm_distance_rogerstanimoto),
|
||||
ztest_unit_test(test_arm_distance_russellrao),
|
||||
ztest_unit_test(test_arm_distance_sokalmichener),
|
||||
ztest_unit_test(test_arm_distance_sokalsneath),
|
||||
ztest_unit_test(test_arm_distance_yule)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(distance_u32);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ target_sources(app PRIVATE
|
|||
src/q15.c
|
||||
src/q31.c
|
||||
src/f32.c
|
||||
src/main.c
|
||||
)
|
||||
|
||||
target_sources_ifdef(CONFIG_CMSIS_DSP_FLOAT16 app PRIVATE src/f16.c)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_NEW_API=y
|
||||
CONFIG_NEWLIB_LIBC=y
|
||||
CONFIG_CMSIS_DSP=y
|
||||
CONFIG_CMSIS_DSP_FASTMATH=y
|
||||
|
|
|
@ -86,7 +86,9 @@ static void test_arm_sin_f16(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void test_arm_sqrt_f16(void)
|
||||
ZTEST_SUITE(fastmath_f16, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ZTEST(fastmath_f16, test_arm_sqrt_f16)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_sqrt);
|
||||
|
@ -155,10 +157,10 @@ static void test_arm_vlog_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_vlog_f16, all, in_log, ref_log, 25);
|
||||
DEFINE_TEST_VARIANT3(arm_vlog_f16, 3, in_log, ref_log, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_vlog_f16, 8, in_log, ref_log, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_vlog_f16, 11, in_log, ref_log, 11);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f16, arm_vlog_f16, all, in_log, ref_log, 25);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f16, arm_vlog_f16, 3, in_log, ref_log, 3);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f16, arm_vlog_f16, 8, in_log, ref_log, 8);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f16, arm_vlog_f16, 11, in_log, ref_log, 11);
|
||||
|
||||
static void test_arm_vexp_f16(
|
||||
const uint16_t *input1, const uint16_t *ref, size_t length)
|
||||
|
@ -187,12 +189,12 @@ static void test_arm_vexp_f16(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_vexp_f16, all, in_exp, ref_exp, 52);
|
||||
DEFINE_TEST_VARIANT3(arm_vexp_f16, 3, in_exp, ref_exp, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_vexp_f16, 8, in_exp, ref_exp, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_vexp_f16, 11, in_exp, ref_exp, 11);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f16, arm_vexp_f16, all, in_exp, ref_exp, 52);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f16, arm_vexp_f16, 3, in_exp, ref_exp, 3);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f16, arm_vexp_f16, 8, in_exp, ref_exp, 8);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f16, arm_vexp_f16, 11, in_exp, ref_exp, 11);
|
||||
|
||||
static void test_arm_vinverse_f16(void)
|
||||
ZTEST(fastmath_f16, test_arm_vinverse_f16)
|
||||
{
|
||||
size_t length = ARRAY_SIZE(ref_vinverse);
|
||||
float16_t *output;
|
||||
|
@ -219,25 +221,4 @@ static void test_arm_vinverse_f16(void)
|
|||
free(output);
|
||||
}
|
||||
|
||||
void test_fastmath_f16(void)
|
||||
{
|
||||
ztest_test_suite(fastmath_f16,
|
||||
/* NOTE: F16 sin and cos are not implemented for now */
|
||||
/* ztest_unit_test(test_arm_cos_f16), */
|
||||
/* ztest_unit_test(test_arm_sin_f16), */
|
||||
ztest_unit_test(test_arm_sqrt_f16),
|
||||
ztest_unit_test(test_arm_vlog_f16_all),
|
||||
ztest_unit_test(test_arm_vlog_f16_3),
|
||||
ztest_unit_test(test_arm_vlog_f16_8),
|
||||
ztest_unit_test(test_arm_vlog_f16_11),
|
||||
ztest_unit_test(test_arm_vexp_f16_all),
|
||||
ztest_unit_test(test_arm_vexp_f16_3),
|
||||
ztest_unit_test(test_arm_vexp_f16_8),
|
||||
ztest_unit_test(test_arm_vexp_f16_11),
|
||||
ztest_unit_test(test_arm_vinverse_f16)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(fastmath_f16);
|
||||
}
|
||||
|
||||
/* TODO: Add inverse test */
|
||||
|
|
|
@ -17,7 +17,9 @@
|
|||
#define REL_ERROR_THRESH (1.0e-6)
|
||||
#define ABS_ERROR_THRESH (1.0e-5)
|
||||
|
||||
static void test_arm_cos_f32(void)
|
||||
ZTEST_SUITE(fastmath_f32, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ZTEST(fastmath_f32, test_arm_cos_f32)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_angles);
|
||||
|
@ -47,7 +49,7 @@ static void test_arm_cos_f32(void)
|
|||
free(output);
|
||||
}
|
||||
|
||||
static void test_arm_sin_f32(void)
|
||||
ZTEST(fastmath_f32, test_arm_sin_f32)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_angles);
|
||||
|
@ -77,7 +79,7 @@ static void test_arm_sin_f32(void)
|
|||
free(output);
|
||||
}
|
||||
|
||||
static void test_arm_sqrt_f32(void)
|
||||
ZTEST(fastmath_f32, test_arm_sqrt_f32)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_sqrt);
|
||||
|
@ -146,10 +148,10 @@ static void test_arm_vlog_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_vlog_f32, all, in_log, ref_log, 25);
|
||||
DEFINE_TEST_VARIANT3(arm_vlog_f32, 3, in_log, ref_log, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_vlog_f32, 8, in_log, ref_log, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_vlog_f32, 11, in_log, ref_log, 11);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f32, arm_vlog_f32, all, in_log, ref_log, 25);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f32, arm_vlog_f32, 3, in_log, ref_log, 3);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f32, arm_vlog_f32, 8, in_log, ref_log, 8);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f32, arm_vlog_f32, 11, in_log, ref_log, 11);
|
||||
|
||||
static void test_arm_vexp_f32(
|
||||
const uint32_t *input1, const uint32_t *ref, size_t length)
|
||||
|
@ -178,26 +180,7 @@ static void test_arm_vexp_f32(
|
|||
free(output);
|
||||
}
|
||||
|
||||
DEFINE_TEST_VARIANT3(arm_vexp_f32, all, in_exp, ref_exp, 52);
|
||||
DEFINE_TEST_VARIANT3(arm_vexp_f32, 3, in_exp, ref_exp, 3);
|
||||
DEFINE_TEST_VARIANT3(arm_vexp_f32, 8, in_exp, ref_exp, 8);
|
||||
DEFINE_TEST_VARIANT3(arm_vexp_f32, 11, in_exp, ref_exp, 11);
|
||||
|
||||
void test_fastmath_f32(void)
|
||||
{
|
||||
ztest_test_suite(fastmath_f32,
|
||||
ztest_unit_test(test_arm_cos_f32),
|
||||
ztest_unit_test(test_arm_sin_f32),
|
||||
ztest_unit_test(test_arm_sqrt_f32),
|
||||
ztest_unit_test(test_arm_vlog_f32_all),
|
||||
ztest_unit_test(test_arm_vlog_f32_3),
|
||||
ztest_unit_test(test_arm_vlog_f32_8),
|
||||
ztest_unit_test(test_arm_vlog_f32_11),
|
||||
ztest_unit_test(test_arm_vexp_f32_all),
|
||||
ztest_unit_test(test_arm_vexp_f32_3),
|
||||
ztest_unit_test(test_arm_vexp_f32_8),
|
||||
ztest_unit_test(test_arm_vexp_f32_11)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(fastmath_f32);
|
||||
}
|
||||
DEFINE_TEST_VARIANT3(fastmath_f32, arm_vexp_f32, all, in_exp, ref_exp, 52);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f32, arm_vexp_f32, 3, in_exp, ref_exp, 3);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f32, arm_vexp_f32, 8, in_exp, ref_exp, 8);
|
||||
DEFINE_TEST_VARIANT3(fastmath_f32, arm_vexp_f32, 11, in_exp, ref_exp, 11);
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Stephanos Ioannidis <root@stephanos.io>
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <ztest.h>
|
||||
#include <zephyr.h>
|
||||
|
||||
extern void test_fastmath_q15(void);
|
||||
extern void test_fastmath_q31(void);
|
||||
extern void test_fastmath_f16(void);
|
||||
extern void test_fastmath_f32(void);
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
test_fastmath_q15();
|
||||
test_fastmath_q31();
|
||||
#ifdef CONFIG_CMSIS_DSP_FLOAT16
|
||||
test_fastmath_f16();
|
||||
#endif
|
||||
test_fastmath_f32();
|
||||
}
|
|
@ -16,7 +16,9 @@
|
|||
#define SNR_ERROR_THRESH ((float32_t)70)
|
||||
#define ABS_ERROR_THRESH ((q15_t)10)
|
||||
|
||||
static void test_arm_cos_q15(void)
|
||||
ZTEST_SUITE(fastmath_q15, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ZTEST(fastmath_q15, test_arm_cos_q15)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_angles);
|
||||
|
@ -44,7 +46,7 @@ static void test_arm_cos_q15(void)
|
|||
free(output);
|
||||
}
|
||||
|
||||
static void test_arm_sin_q15(void)
|
||||
ZTEST(fastmath_q15, test_arm_sin_q15)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_angles);
|
||||
|
@ -72,7 +74,7 @@ static void test_arm_sin_q15(void)
|
|||
free(output);
|
||||
}
|
||||
|
||||
static void test_arm_sqrt_q15(void)
|
||||
ZTEST(fastmath_q15, test_arm_sqrt_q15)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_sqrt);
|
||||
|
@ -112,7 +114,7 @@ static void test_arm_sqrt_q15(void)
|
|||
free(output);
|
||||
}
|
||||
|
||||
static void test_arm_divide_q15(void)
|
||||
ZTEST(fastmath_q15, test_arm_divide_q15)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(ref_divide);
|
||||
|
@ -153,15 +155,3 @@ static void test_arm_divide_q15(void)
|
|||
free(output);
|
||||
free(shift);
|
||||
}
|
||||
|
||||
void test_fastmath_q15(void)
|
||||
{
|
||||
ztest_test_suite(fastmath_q15,
|
||||
ztest_unit_test(test_arm_cos_q15),
|
||||
ztest_unit_test(test_arm_sin_q15),
|
||||
ztest_unit_test(test_arm_sqrt_q15),
|
||||
ztest_unit_test(test_arm_divide_q15)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(fastmath_q15);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
#define SNR_ERROR_THRESH ((float32_t)100)
|
||||
#define ABS_ERROR_THRESH ((q31_t)2200)
|
||||
|
||||
static void test_arm_cos_q31(void)
|
||||
ZTEST_SUITE(fastmath_q31, NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
ZTEST(fastmath_q31, test_arm_cos_q31)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_angles);
|
||||
|
@ -44,7 +46,7 @@ static void test_arm_cos_q31(void)
|
|||
free(output);
|
||||
}
|
||||
|
||||
static void test_arm_sin_q31(void)
|
||||
ZTEST(fastmath_q31, test_arm_sin_q31)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_angles);
|
||||
|
@ -72,7 +74,7 @@ static void test_arm_sin_q31(void)
|
|||
free(output);
|
||||
}
|
||||
|
||||
static void test_arm_sqrt_q31(void)
|
||||
ZTEST(fastmath_q31, test_arm_sqrt_q31)
|
||||
{
|
||||
size_t index;
|
||||
size_t length = ARRAY_SIZE(in_sqrt);
|
||||
|
@ -111,14 +113,3 @@ static void test_arm_sqrt_q31(void)
|
|||
/* Free output buffer */
|
||||
free(output);
|
||||
}
|
||||
|
||||
void test_fastmath_q31(void)
|
||||
{
|
||||
ztest_test_suite(fastmath_q31,
|
||||
ztest_unit_test(test_arm_cos_q31),
|
||||
ztest_unit_test(test_arm_sin_q31),
|
||||
ztest_unit_test(test_arm_sqrt_q31)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(fastmath_q31);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue