-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: lib: cmsis_dsp: transform: Add CF16 tests for 1.9.0
This commit adds the transform CF16 test patterns and implementations for the CMSIS-DSP 1.9.0. Signed-off-by: Stephanos Ioannidis <[email protected]>
- Loading branch information
1 parent
600ca01
commit 6547025
Showing
7 changed files
with
12,678 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
/* | ||
* Copyright (c) 2021 Stephanos Ioannidis <[email protected]> | ||
* Copyright (C) 2010-2021 ARM Limited or its affiliates. All rights reserved. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <ztest.h> | ||
#include <zephyr.h> | ||
#include <stdlib.h> | ||
#include <arm_math_f16.h> | ||
#include <arm_const_structs.h> | ||
#include "../../common/test_common.h" | ||
|
||
#include "cf16.pat" | ||
|
||
#define SNR_ERROR_THRESH ((float32_t)58) | ||
|
||
static void test_arm_cfft_f16_cmplx_backend( | ||
bool inverse, const uint16_t *input, const uint16_t *ref, size_t length) | ||
{ | ||
arm_cfft_instance_f16 inst; | ||
float16_t *output; | ||
arm_status status; | ||
|
||
/* Initialise instance */ | ||
status = arm_cfft_init_f16(&inst, length / 2); | ||
|
||
zassert_equal(status, ARM_MATH_SUCCESS, | ||
ASSERT_MSG_INCORRECT_COMP_RESULT); | ||
|
||
/* Allocate output buffer */ | ||
output = malloc(length * sizeof(float16_t)); | ||
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED); | ||
|
||
/* Load data in place */ | ||
memcpy(output, input, length * sizeof(float16_t)); | ||
|
||
/* Run test function */ | ||
arm_cfft_f16(&inst, output, inverse, true); | ||
|
||
/* Validate output */ | ||
zassert_true( | ||
test_snr_error_f16(length, output, (float16_t *)ref, | ||
SNR_ERROR_THRESH), | ||
ASSERT_MSG_SNR_LIMIT_EXCEED); | ||
|
||
/* Free output buffer */ | ||
free(output); | ||
} | ||
|
||
static void test_arm_cfft_f16_cmplx( | ||
const uint16_t *input, const uint16_t *ref, size_t length) | ||
{ | ||
test_arm_cfft_f16_cmplx_backend(false, input, ref, length); | ||
} | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_16, | ||
in_cfft_noisy_16, ref_cfft_noisy_16, 32); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_32, | ||
in_cfft_noisy_32, ref_cfft_noisy_32, 64); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_64, | ||
in_cfft_noisy_64, ref_cfft_noisy_64, 128); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_128, | ||
in_cfft_noisy_128, ref_cfft_noisy_128, 256); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_256, | ||
in_cfft_noisy_256, ref_cfft_noisy_256, 512); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_512, | ||
in_cfft_noisy_512, ref_cfft_noisy_512, 1024); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_1024, | ||
in_cfft_noisy_1024, ref_cfft_noisy_1024, 2048); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_2048, | ||
in_cfft_noisy_2048, ref_cfft_noisy_2048, 4096); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, noisy_4096, | ||
in_cfft_noisy_4096, ref_cfft_noisy_4096, 8192); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_16, | ||
in_cfft_step_16, ref_cfft_step_16, 32); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_32, | ||
in_cfft_step_32, ref_cfft_step_32, 64); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_64, | ||
in_cfft_step_64, ref_cfft_step_64, 128); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_128, | ||
in_cfft_step_128, ref_cfft_step_128, 256); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_256, | ||
in_cfft_step_256, ref_cfft_step_256, 512); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_512, | ||
in_cfft_step_512, ref_cfft_step_512, 1024); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_1024, | ||
in_cfft_step_1024, ref_cfft_step_1024, 2048); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_2048, | ||
in_cfft_step_2048, ref_cfft_step_2048, 4096); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cfft_f16_cmplx, step_4096, | ||
in_cfft_step_4096, ref_cfft_step_4096, 8192); | ||
|
||
static void test_arm_cifft_f16_cmplx( | ||
const uint16_t *input, const uint16_t *ref, size_t length) | ||
{ | ||
test_arm_cfft_f16_cmplx_backend(true, input, ref, length); | ||
} | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_16, | ||
in_cifft_noisy_16, in_cfft_noisy_16, 32); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_32, | ||
in_cifft_noisy_32, in_cfft_noisy_32, 64); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_64, | ||
in_cifft_noisy_64, in_cfft_noisy_64, 128); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_128, | ||
in_cifft_noisy_128, in_cfft_noisy_128, 256); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_256, | ||
in_cifft_noisy_256, in_cfft_noisy_256, 512); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_512, | ||
in_cifft_noisy_512, in_cfft_noisy_512, 1024); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_1024, | ||
in_cifft_noisy_1024, in_cfft_noisy_1024, 2048); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_2048, | ||
in_cifft_noisy_2048, in_cfft_noisy_2048, 4096); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, noisy_4096, | ||
in_cifft_noisy_4096, in_cfft_noisy_4096, 8192); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_16, | ||
in_cifft_step_16, in_cfft_step_16, 32); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_32, | ||
in_cifft_step_32, in_cfft_step_32, 64); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_64, | ||
in_cifft_step_64, in_cfft_step_64, 128); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_128, | ||
in_cifft_step_128, in_cfft_step_128, 256); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_256, | ||
in_cifft_step_256, in_cfft_step_256, 512); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_512, | ||
in_cifft_step_512, in_cfft_step_512, 1024); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_1024, | ||
in_cifft_step_1024, in_cfft_step_1024, 2048); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_2048, | ||
in_cifft_step_2048, in_cfft_step_2048, 4096); | ||
|
||
DEFINE_TEST_VARIANT3(arm_cifft_f16_cmplx, step_4096, | ||
in_cifft_step_4096, in_cfft_step_4096, 8192); | ||
|
||
void test_transform_cf16(void) | ||
{ | ||
ztest_test_suite(transform_cf16, | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_16), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_16), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_32), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_32), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_64), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_64), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_128), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_128), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_256), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_256), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_512), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_512), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_1024), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_1024), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_2048), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_2048), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_noisy_4096), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_noisy_4096), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_16), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_16), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_32), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_32), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_64), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_64), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_128), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_128), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_256), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_256), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_512), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_512), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_1024), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_1024), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_2048), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_2048), | ||
ztest_unit_test(test_arm_cfft_f16_cmplx_step_4096), | ||
ztest_unit_test(test_arm_cifft_f16_cmplx_step_4096) | ||
); | ||
|
||
ztest_run_test_suite(transform_cf16); | ||
} |
Oops, something went wrong.