Ver Fonte

上傳檔案到 'app/main/CTO20220622/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/transform_tests'

rita há 2 anos atrás
pai
commit
941b28334a

+ 181 - 0
app/main/CTO20220622/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/transform_tests/transform_templates.h

@@ -0,0 +1,181 @@
+#ifndef _TRANSFORM_TEMPLATES_H_
+#define _TRANSFORM_TEMPLATES_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Includes */
+/*--------------------------------------------------------------------------------*/
+
+#include "test_templates.h"
+#include <string.h>             /* memcpy() */
+
+/*--------------------------------------------------------------------------------*/
+/* Group Specific Templates */
+/*--------------------------------------------------------------------------------*/
+
+/**
+ * Comparison SNR thresholds for the data types used in transform_tests.
+ */
+#define TRANSFORM_SNR_THRESHOLD_float32_t 90
+#define TRANSFORM_SNR_THRESHOLD_q31_t     90
+#define TRANSFORM_SNR_THRESHOLD_q15_t     30
+
+#define DCT4_TRANSFORM_SNR_THRESHOLD_float32_t 80
+#define DCT4_TRANSFORM_SNR_THRESHOLD_q31_t     75
+#define DCT4_TRANSFORM_SNR_THRESHOLD_q15_t     11
+
+/**
+ *  Compare the outputs from the function under test and the reference
+ *  function using SNR.
+ */
+#define TRANSFORM_SNR_COMPARE_INTERFACE(block_size,     \
+                                        output_type)    \
+    do                                                  \
+    {                                                   \
+        TEST_CONVERT_AND_ASSERT_SNR(                    \
+            transform_fft_output_f32_ref,               \
+            (output_type *) transform_fft_output_ref,   \
+            transform_fft_output_f32_fut,               \
+            (output_type *) transform_fft_output_fut,   \
+            block_size,                                 \
+            output_type,                                \
+            TRANSFORM_SNR_THRESHOLD_##output_type       \
+            );                                          \
+    } while (0)
+    
+/**
+ *  Compare the outputs from the function under test and the reference
+ *  function using SNR.
+ */
+#define DCT_TRANSFORM_SNR_COMPARE_INTERFACE(block_size,  \
+                                            output_type) \
+    do                                                   \
+    {                                                    \
+        TEST_CONVERT_AND_ASSERT_SNR(                     \
+            transform_fft_output_f32_ref,                \
+            (output_type *) transform_fft_output_ref,    \
+            transform_fft_output_f32_fut,                \
+            (output_type *) transform_fft_output_fut,    \
+            block_size,                                  \
+            output_type,                                 \
+            DCT4_TRANSFORM_SNR_THRESHOLD_##output_type   \
+            );                                           \
+    } while (0)                                           \
+
+/**
+ *  Specialization on #TRANSFORM_SNR_COMPARE_INTERFACE() to fix the block_size
+ *  for complex datasets.
+ */
+#define TRANSFORM_SNR_COMPARE_CMPLX_INTERFACE(block_size, output_type)  \
+    /* Complex numbers have two components*/                            \
+    TRANSFORM_SNR_COMPARE_INTERFACE(block_size * 2, output_type )
+
+/**
+ * This macro copys data from the input_ptr into input arrays.
+ *
+ * Some functions modify their input data; in order to provide the same data to
+ * multiple tests, copies must be made so the changes from one function don't
+ * impact the others.
+ */
+#define TRANSFORM_COPY_INPUTS(input_ptr,        \
+                              bytes)            \
+    do                                          \
+    {                                           \
+        memcpy(                                 \
+            transform_fft_input_fut,            \
+            input_ptr,                          \
+            bytes);                             \
+        memcpy(                                 \
+            transform_fft_input_ref,            \
+            input_ptr,                          \
+            bytes);                             \
+    } while (0)
+
+/**
+ * This macro copys data from the input_ptr into input arrays. It also creates
+ * symmetric input data for rfft inverse.
+ *
+ * The 4.534234f just makes the middle entry of the array semi random.  It's
+ * actual value doesn't seem to matter much.
+ *
+ * Some functions modify their input data; in order to provide the same data to
+ * multiple tests, copies must be made so the changes from one function don't
+ * impact the others.
+ */
+#define TRANSFORM_PREPARE_INVERSE_INPUTS(input_ptr,                              \
+                              fftlen, input_type, bytes)                         \
+    do                                                                           \
+    {                                                                            \
+        uint32_t i;                                                              \
+                                                                                 \
+        memcpy(                                                                  \
+            transform_fft_input_fut,                                             \
+            input_ptr,                                                           \
+            bytes);                                                              \
+                                                                                 \
+        ((input_type*)transform_fft_input_fut)[1] = 0;                           \
+        ((input_type*)transform_fft_input_fut)[fftlen + 0] = 0;                  \
+        ((input_type*)transform_fft_input_fut)[fftlen + 1] = 0;                  \
+        for(i=1;i<fftlen/2;i++)                                                  \
+        {                                                                        \
+           *((input_type*)transform_fft_input_fut + fftlen + 2*i + 0) =          \
+               *((input_type*)transform_fft_input_fut + fftlen - 2*i + 0);       \
+           *((input_type*)transform_fft_input_fut + fftlen + 2*i + 1) =          \
+               -(*((input_type*)transform_fft_input_fut + fftlen - 2*i + 1));    \
+                                                                                 \
+        }                                                                        \
+                                                                                 \
+        memcpy(                                                                  \
+            transform_fft_input_ref,                                             \
+            transform_fft_input_fut,                                             \
+            bytes * 2);                                                          \
+    } while (0)
+
+/**
+ * This macro copys data from the input_ptr into the in-place input arrays.
+ *
+ * Some functions modify their input data; in order to provide the same data to
+ * multiple tests, copies must be made so the changes from one function don't
+ * impact the others.
+ */
+#define TRANSFORM_PREPARE_INPLACE_INPUTS_DOWNSHIFT(input_ptr,       \
+                                         bytes,                     \
+                                         type)                      \
+    do                                                              \
+    {                                                               \
+        uint32_t i;                                                 \
+        memcpy(                                                     \
+            transform_fft_inplace_input_fut,                        \
+            input_ptr,                                              \
+            bytes);                                                 \
+        memcpy(                                                     \
+            transform_fft_inplace_input_ref,                        \
+            input_ptr,                                              \
+            bytes);                                                 \
+        for(i=0;i<bytes/sizeof(type);i++) {                         \
+            *((type*)transform_fft_inplace_input_fut + i) >>= 1;    \
+            *((type*)transform_fft_inplace_input_ref + i) >>= 1;}   \
+    } while (0)
+
+/**
+ * This macro copys data from the input_ptr into the in-place input arrays.
+ *
+ * Some functions modify their input data; in order to provide the same data to
+ * multiple tests, copies must be made so the changes from one function don't
+ * impact the others.
+ */
+#define TRANSFORM_PREPARE_INPLACE_INPUTS(input_ptr, \
+                                         bytes)     \
+    do                                              \
+    {                                               \
+        memcpy(                                     \
+            transform_fft_inplace_input_fut,        \
+            input_ptr,                              \
+            bytes);                                 \
+        memcpy(                                     \
+            transform_fft_inplace_input_ref,        \
+            input_ptr,                              \
+            bytes);                                 \
+    } while (0)
+
+
+#endif /* _TRANSFORM_TEMPLATES_H_ */

+ 48 - 0
app/main/CTO20220622/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/transform_tests/transform_test_data.h

@@ -0,0 +1,48 @@
+#ifndef _TRANSFORM_TEST_DATA_H_
+#define _TRANSFORM_TEST_DATA_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Includes */
+/*--------------------------------------------------------------------------------*/
+
+#include "arr_desc.h"
+#include "arm_math.h"
+
+/*--------------------------------------------------------------------------------*/
+/* Macros and Defines */
+/*--------------------------------------------------------------------------------*/
+
+#define TRANSFORM_MAX_FFT_LEN 4096
+#define TRANFORM_BIGGEST_INPUT_TYPE float32_t
+
+/*--------------------------------------------------------------------------------*/
+/* Variable Declarations */
+/*--------------------------------------------------------------------------------*/
+
+/* Lengths are multiplied by 2 to accomodate complex numbers*/
+extern float32_t transform_fft_output_fut[TRANSFORM_MAX_FFT_LEN * 2];
+extern float32_t transform_fft_output_ref[TRANSFORM_MAX_FFT_LEN * 2];
+extern float32_t transform_fft_input_fut[TRANSFORM_MAX_FFT_LEN * 2];
+extern float32_t transform_fft_input_ref[TRANSFORM_MAX_FFT_LEN * 2];
+extern float32_t transform_fft_output_f32_fut[TRANSFORM_MAX_FFT_LEN * 2];
+extern float32_t transform_fft_output_f32_ref[TRANSFORM_MAX_FFT_LEN * 2];
+extern float32_t * transform_fft_inplace_input_fut;
+extern float32_t * transform_fft_inplace_input_ref;
+extern float32_t transform_fft_f32_inputs[TRANSFORM_MAX_FFT_LEN * 2];
+extern q31_t transform_fft_q31_inputs[TRANSFORM_MAX_FFT_LEN * 2];
+extern q15_t * transform_fft_q15_inputs;
+extern q15_t dct4_transform_fft_q15_inputs[TRANSFORM_MAX_FFT_LEN * 2];
+
+/* FFT Lengths */
+ARR_DESC_DECLARE(transform_radix2_fftlens);
+ARR_DESC_DECLARE(transform_radix4_fftlens);
+ARR_DESC_DECLARE(transform_rfft_fftlens);
+ARR_DESC_DECLARE(transform_rfft_fast_fftlens);
+ARR_DESC_DECLARE(transform_dct_fftlens);
+
+/* CFFT Structs */
+ARR_DESC_DECLARE(transform_cfft_f32_structs);
+ARR_DESC_DECLARE(transform_cfft_q31_structs);
+ARR_DESC_DECLARE(transform_cfft_q15_structs);
+
+#endif /* _TRANSFORM_TEST_DATA_H_ */

+ 9 - 0
app/main/CTO20220622/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/transform_tests/transform_test_group.h

@@ -0,0 +1,9 @@
+#ifndef _TRANSFORM_TEST_GROUP_H_
+#define _TRANSFORM_TEST_GROUP_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Declare Test Groups */
+/*--------------------------------------------------------------------------------*/
+JTEST_DECLARE_GROUP(transform_tests);
+
+#endif /* _TRANSFORM_TEST_GROUP_H_ */

+ 13 - 0
app/main/CTO20220622/Drivers/CMSIS/DSP/DSP_Lib_TestSuite/Common/inc/transform_tests/transform_tests.h

@@ -0,0 +1,13 @@
+#ifndef _TRANSFORM_TESTS_H_
+#define _TRANSFORM_TESTS_H_
+
+/*--------------------------------------------------------------------------------*/
+/* Test/Group Declarations */
+/*--------------------------------------------------------------------------------*/
+JTEST_DECLARE_GROUP(cfft_tests);
+JTEST_DECLARE_GROUP(cfft_family_tests);
+JTEST_DECLARE_GROUP(dct4_tests);
+JTEST_DECLARE_GROUP(rfft_tests);
+JTEST_DECLARE_GROUP(rfft_fast_tests);
+
+#endif /* _TRANSFORM_TESTS_H_ */