tests: lib: cmsis_dsp: statistics: Add F16 tests for 1.9.0

This commit adds the statistics F16 test patterns and implementations
for the CMSIS-DSP 1.9.0.

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
This commit is contained in:
Stephanos Ioannidis 2021-08-21 17:42:27 +09:00 committed by Carles Cufí
commit 05423de993
4 changed files with 791 additions and 2 deletions

View file

@ -4,5 +4,13 @@ cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(cmsis_dsp_statistics)
FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
target_sources(app PRIVATE
src/q7.c
src/q15.c
src/q31.c
src/f32.c
src/f64.c
src/main.c
)
target_sources_ifdef(CONFIG_CMSIS_DSP_FLOAT16 app PRIVATE src/f16.c)

View file

@ -0,0 +1,484 @@
/*
* Copyright (c) 2021 Stephanos Ioannidis <root@stephanos.io>
* 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 "../../common/test_common.h"
#include "f16.pat"
#define SNR_ERROR_THRESH ((float32_t)48)
#define REL_ERROR_THRESH (6.0e-3)
#define SNR_ERROR_THRESH_KB ((float32_t)40)
#define REL_ERROR_THRESH_KB (5.0e-3)
#define ABS_ERROR_THRESH_KB (5.0e-3)
static void test_arm_max_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t val;
uint32_t index;
/* Run test function */
arm_max_f16((float16_t *)input1, length, &val, &index);
/* Validate output */
zassert_equal(val, ((float16_t *)ref_max_val)[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
zassert_equal(index, ref_max_idx[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
}
DEFINE_TEST_VARIANT3(arm_max_f16, 7, in_com1, 0, 7);
DEFINE_TEST_VARIANT3(arm_max_f16, 16, in_com1, 1, 16);
DEFINE_TEST_VARIANT3(arm_max_f16, 23, in_com1, 2, 23);
static void test_arm_max_no_idx_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t val;
/* Run test function */
arm_max_no_idx_f16((float16_t *)input1, length, &val);
/* Validate output */
zassert_equal(val, ((float16_t *)ref_max_val)[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
}
DEFINE_TEST_VARIANT3(arm_max_no_idx_f16, 7, in_com1, 0, 7);
DEFINE_TEST_VARIANT3(arm_max_no_idx_f16, 16, in_com1, 1, 16);
DEFINE_TEST_VARIANT3(arm_max_no_idx_f16, 23, in_com1, 2, 23);
static void test_arm_min_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t val;
uint32_t index;
/* Run test function */
arm_min_f16((float16_t *)input1, length, &val, &index);
/* Validate output */
zassert_equal(val, ((float16_t *)ref_min_val)[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
zassert_equal(index, ref_min_idx[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
}
DEFINE_TEST_VARIANT3(arm_min_f16, 7, in_com1, 0, 7);
DEFINE_TEST_VARIANT3(arm_min_f16, 16, in_com1, 1, 16);
DEFINE_TEST_VARIANT3(arm_min_f16, 23, in_com1, 2, 23);
static void test_arm_absmax_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t val;
uint32_t index;
/* Run test function */
arm_absmax_f16((float16_t *)input1, length, &val, &index);
/* Validate output */
zassert_equal(val, ((float16_t *)ref_absmax_val)[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
zassert_equal(index, ref_absmax_idx[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
}
DEFINE_TEST_VARIANT3(arm_absmax_f16, 7, in_absminmax, 0, 7);
DEFINE_TEST_VARIANT3(arm_absmax_f16, 16, in_absminmax, 1, 16);
DEFINE_TEST_VARIANT3(arm_absmax_f16, 23, in_absminmax, 2, 23);
static void test_arm_absmin_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t val;
uint32_t index;
/* Run test function */
arm_absmin_f16((float16_t *)input1, length, &val, &index);
/* Validate output */
zassert_equal(val, ((float16_t *)ref_absmin_val)[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
zassert_equal(index, ref_absmin_idx[ref_index],
ASSERT_MSG_INCORRECT_COMP_RESULT);
}
DEFINE_TEST_VARIANT3(arm_absmin_f16, 7, in_absminmax, 0, 7);
DEFINE_TEST_VARIANT3(arm_absmin_f16, 16, in_absminmax, 1, 16);
DEFINE_TEST_VARIANT3(arm_absmin_f16, 23, in_absminmax, 2, 23);
static void test_arm_mean_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t ref[1];
float16_t *output;
/* Load reference */
ref[0] = ((float16_t *)ref_mean)[ref_index];
/* Allocate output buffer */
output = malloc(1 * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
arm_mean_f16((float16_t *)input1, length, &output[0]);
/* Validate output */
zassert_true(
test_snr_error_f16(1, output, ref, SNR_ERROR_THRESH),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_rel_error_f16(1, output, ref, REL_ERROR_THRESH),
ASSERT_MSG_REL_ERROR_LIMIT_EXCEED);
/* Free output buffer */
free(output);
}
DEFINE_TEST_VARIANT3(arm_mean_f16, 7, in_com2, 0, 7);
DEFINE_TEST_VARIANT3(arm_mean_f16, 16, in_com2, 1, 16);
DEFINE_TEST_VARIANT3(arm_mean_f16, 23, in_com2, 2, 23);
static void test_arm_power_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t ref[1];
float16_t *output;
/* Load reference */
ref[0] = ((float16_t *)ref_power)[ref_index];
/* Allocate output buffer */
output = malloc(1 * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
arm_power_f16((float16_t *)input1, length, &output[0]);
/* Validate output */
zassert_true(
test_snr_error_f16(1, output, ref, SNR_ERROR_THRESH),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_rel_error_f16(1, output, ref, REL_ERROR_THRESH),
ASSERT_MSG_REL_ERROR_LIMIT_EXCEED);
/* Free output buffer */
free(output);
}
DEFINE_TEST_VARIANT3(arm_power_f16, 7, in_com1, 0, 7);
DEFINE_TEST_VARIANT3(arm_power_f16, 16, in_com1, 1, 16);
DEFINE_TEST_VARIANT3(arm_power_f16, 23, in_com1, 2, 23);
static void test_arm_rms_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t ref[1];
float16_t *output;
/* Load reference */
ref[0] = ((float16_t *)ref_rms)[ref_index];
/* Allocate output buffer */
output = malloc(1 * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
arm_rms_f16((float16_t *)input1, length, &output[0]);
/* Validate output */
zassert_true(
test_snr_error_f16(1, output, ref, SNR_ERROR_THRESH),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_rel_error_f16(1, output, ref, REL_ERROR_THRESH),
ASSERT_MSG_REL_ERROR_LIMIT_EXCEED);
/* Free output buffer */
free(output);
}
DEFINE_TEST_VARIANT3(arm_rms_f16, 7, in_com1, 0, 7);
DEFINE_TEST_VARIANT3(arm_rms_f16, 16, in_com1, 1, 16);
DEFINE_TEST_VARIANT3(arm_rms_f16, 23, in_com1, 2, 23);
static void test_arm_std_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t ref[1];
float16_t *output;
/* Load reference */
ref[0] = ((float16_t *)ref_std)[ref_index];
/* Allocate output buffer */
output = malloc(1 * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
arm_std_f16((float16_t *)input1, length, &output[0]);
/* Validate output */
zassert_true(
test_snr_error_f16(1, output, ref, SNR_ERROR_THRESH),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_rel_error_f16(1, output, ref, REL_ERROR_THRESH),
ASSERT_MSG_REL_ERROR_LIMIT_EXCEED);
/* Free output buffer */
free(output);
}
DEFINE_TEST_VARIANT3(arm_std_f16, 7, in_com1, 0, 7);
DEFINE_TEST_VARIANT3(arm_std_f16, 16, in_com1, 1, 16);
DEFINE_TEST_VARIANT3(arm_std_f16, 23, in_com1, 2, 23);
static void test_arm_var_f16(
const uint16_t *input1, int ref_index, size_t length)
{
float16_t ref[1];
float16_t *output;
/* Load reference */
ref[0] = ((float16_t *)ref_var)[ref_index];
/* Allocate output buffer */
output = malloc(1 * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
arm_var_f16((float16_t *)input1, length, &output[0]);
/* Validate output */
zassert_true(
test_snr_error_f16(1, output, ref, SNR_ERROR_THRESH),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_rel_error_f16(1, output, ref, REL_ERROR_THRESH),
ASSERT_MSG_REL_ERROR_LIMIT_EXCEED);
/* Free output buffer */
free(output);
}
DEFINE_TEST_VARIANT3(arm_var_f16, 7, in_com1, 0, 7);
DEFINE_TEST_VARIANT3(arm_var_f16, 16, in_com1, 1, 16);
DEFINE_TEST_VARIANT3(arm_var_f16, 23, in_com1, 2, 23);
static void test_arm_entropy_f16(void)
{
size_t index;
size_t length = in_entropy_dim[0];
const float16_t *ref = (float16_t *)ref_entropy;
const float16_t *input = (float16_t *)in_entropy;
float16_t *output;
__ASSERT_NO_MSG(ARRAY_SIZE(in_entropy_dim) > length);
__ASSERT_NO_MSG(ARRAY_SIZE(ref_entropy) >= length);
/* Allocate output buffer */
output = malloc(length * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
for (index = 0; index < length; index++) {
output[index] =
arm_entropy_f16(input, in_entropy_dim[index + 1]);
input += in_entropy_dim[index + 1];
}
/* Validate output */
zassert_true(
test_snr_error_f16(length, ref, output, SNR_ERROR_THRESH),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_near_equal_f16(length, ref, output, REL_ERROR_THRESH),
ASSERT_MSG_REL_ERROR_LIMIT_EXCEED);
/* Free output buffer */
free(output);
}
static void test_arm_logsumexp_f16(void)
{
size_t index;
size_t length = in_logsumexp_dim[0];
const float16_t *ref = (float16_t *)ref_logsumexp;
const float16_t *input = (float16_t *)in_logsumexp;
float16_t *output;
__ASSERT_NO_MSG(ARRAY_SIZE(in_logsumexp_dim) > length);
__ASSERT_NO_MSG(ARRAY_SIZE(ref_logsumexp) >= length);
/* Allocate output buffer */
output = malloc(length * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
for (index = 0; index < length; index++) {
output[index] =
arm_logsumexp_f16(input, in_logsumexp_dim[index + 1]);
input += in_logsumexp_dim[index + 1];
}
/* Validate output */
zassert_true(
test_snr_error_f16(length, ref, output, SNR_ERROR_THRESH),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_near_equal_f16(length, ref, output, REL_ERROR_THRESH),
ASSERT_MSG_REL_ERROR_LIMIT_EXCEED);
/* Free output buffer */
free(output);
}
static void test_arm_kullback_leibler_f16(void)
{
size_t index;
size_t length = in_kl_dim[0];
const float16_t *ref = (float16_t *)ref_kl;
const float16_t *input1 = (float16_t *)in_kl1;
const float16_t *input2 = (float16_t *)in_kl2;
float16_t *output;
__ASSERT_NO_MSG(ARRAY_SIZE(in_kl_dim) > length);
__ASSERT_NO_MSG(ARRAY_SIZE(ref_kl) >= length);
/* Allocate output buffer */
output = malloc(length * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
for (index = 0; index < length; index++) {
output[index] =
arm_kullback_leibler_f16(
input1, input2, in_kl_dim[index + 1]);
input1 += in_kl_dim[index + 1];
input2 += in_kl_dim[index + 1];
}
/* Validate output */
zassert_true(
test_snr_error_f16(length, ref, output, SNR_ERROR_THRESH_KB),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_close_error_f16(length, ref, output,
ABS_ERROR_THRESH_KB, REL_ERROR_THRESH_KB),
ASSERT_MSG_ERROR_LIMIT_EXCEED);
/* Free output buffer */
free(output);
}
static void test_arm_logsumexp_dot_prod_f16(void)
{
size_t index;
size_t length = in_logsumexp_dp_dim[0];
const float16_t *ref = (float16_t *)ref_logsumexp_dp;
const float16_t *input1 = (float16_t *)in_logsumexp_dp1;
const float16_t *input2 = (float16_t *)in_logsumexp_dp2;
float16_t *output;
float16_t *tmp;
__ASSERT_NO_MSG(ARRAY_SIZE(in_logsumexp_dp_dim) > length);
__ASSERT_NO_MSG(ARRAY_SIZE(ref_logsumexp_dp) >= length);
/* Allocate buffers */
output = malloc(length * sizeof(float16_t));
zassert_not_null(output, ASSERT_MSG_BUFFER_ALLOC_FAILED);
tmp = malloc(12 * sizeof(float16_t));
zassert_not_null(tmp, ASSERT_MSG_BUFFER_ALLOC_FAILED);
/* Run test function */
for (index = 0; index < length; index++) {
output[index] =
arm_logsumexp_dot_prod_f16(
input1, input2,
in_logsumexp_dp_dim[index + 1], tmp);
input1 += in_logsumexp_dp_dim[index + 1];
input2 += in_logsumexp_dp_dim[index + 1];
}
/* Validate output */
zassert_true(
test_snr_error_f16(length, ref, output, SNR_ERROR_THRESH),
ASSERT_MSG_SNR_LIMIT_EXCEED);
zassert_true(
test_near_equal_f16(length, ref, output, REL_ERROR_THRESH),
ASSERT_MSG_REL_ERROR_LIMIT_EXCEED);
/* Free buffers */
free(output);
free(tmp);
}
void test_statistics_f16(void)
{
ztest_test_suite(statistics_f16,
ztest_unit_test(test_arm_max_f16_7),
ztest_unit_test(test_arm_max_f16_16),
ztest_unit_test(test_arm_max_f16_23),
ztest_unit_test(test_arm_min_f16_7),
ztest_unit_test(test_arm_min_f16_16),
ztest_unit_test(test_arm_min_f16_23),
ztest_unit_test(test_arm_absmax_f16_7),
ztest_unit_test(test_arm_absmax_f16_16),
ztest_unit_test(test_arm_absmax_f16_23),
ztest_unit_test(test_arm_absmin_f16_7),
ztest_unit_test(test_arm_absmin_f16_16),
ztest_unit_test(test_arm_absmin_f16_23),
ztest_unit_test(test_arm_mean_f16_7),
ztest_unit_test(test_arm_mean_f16_16),
ztest_unit_test(test_arm_mean_f16_23),
ztest_unit_test(test_arm_power_f16_7),
ztest_unit_test(test_arm_power_f16_16),
ztest_unit_test(test_arm_power_f16_23),
ztest_unit_test(test_arm_rms_f16_7),
ztest_unit_test(test_arm_rms_f16_16),
ztest_unit_test(test_arm_rms_f16_23),
ztest_unit_test(test_arm_std_f16_7),
ztest_unit_test(test_arm_std_f16_16),
ztest_unit_test(test_arm_std_f16_23),
ztest_unit_test(test_arm_var_f16_7),
ztest_unit_test(test_arm_var_f16_16),
ztest_unit_test(test_arm_var_f16_23),
ztest_unit_test(test_arm_entropy_f16),
ztest_unit_test(test_arm_logsumexp_f16),
ztest_unit_test(test_arm_kullback_leibler_f16),
ztest_unit_test(test_arm_logsumexp_dot_prod_f16),
ztest_unit_test(test_arm_max_no_idx_f16_7),
ztest_unit_test(test_arm_max_no_idx_f16_16),
ztest_unit_test(test_arm_max_no_idx_f16_23)
);
ztest_run_test_suite(statistics_f16);
}

293
tests/lib/cmsis_dsp/statistics/src/f16.pat generated Normal file
View file

@ -0,0 +1,293 @@
static const uint16_t in_com1[300] = {
0xb1cf, 0xb16f, 0x339d, 0x347e, 0x2f20, 0xb482, 0x36d4, 0xb0b6,
0xb4d2, 0x2d71, 0xae32, 0x2f93, 0x26c4, 0xaec8, 0x3696, 0x305e,
0xb55e, 0xb277, 0xb5c8, 0xb7a9, 0xb870, 0xb9ce, 0xb65e, 0x2d39,
0x3604, 0x38f6, 0x2890, 0xa9d7, 0xb165, 0x3173, 0xacee, 0x315b,
0xb20e, 0x353d, 0xb005, 0xb4d6, 0x3530, 0xaf6b, 0x25fd, 0x32d5,
0xb3ff, 0x335f, 0x2aaf, 0xaf94, 0x339d, 0x315a, 0x3801, 0x3656,
0x349a, 0x35d3, 0xb493, 0xb4c8, 0x3626, 0xb2e0, 0xb41b, 0x3703,
0xab5b, 0x2e59, 0xb566, 0xb8d2, 0x9bb4, 0xb454, 0xb5a1, 0x3479,
0xb5da, 0x3046, 0x2baa, 0xb495, 0x33e4, 0x317f, 0xb577, 0x264f,
0x321d, 0x2e04, 0xacf3, 0xb908, 0x2b4e, 0x1c56, 0x399f, 0x2c7c,
0xb00b, 0xaf4f, 0x3195, 0xb52c, 0xb6b8, 0xadf0, 0x25f4, 0x316a,
0xaf32, 0xb83d, 0x2b6b, 0x2e5f, 0x33fc, 0xb113, 0x3714, 0xb603,
0x3434, 0xac5b, 0xb56a, 0x3114, 0x34af, 0x3416, 0x313b, 0xb924,
0xb4dc, 0x34a5, 0xb079, 0xb841, 0xaefd, 0xaa88, 0xbac5, 0x35ee,
0xb330, 0x2d9e, 0x29b6, 0xb1a5, 0xab03, 0xb572, 0xb702, 0xb561,
0x3446, 0x2c6c, 0xab88, 0xb54e, 0xa7a9, 0x38df, 0xb408, 0xafdc,
0x3635, 0x2f30, 0xb685, 0x3511, 0xacec, 0x34cc, 0xafe8, 0x3314,
0xa229, 0xb548, 0x2992, 0xba52, 0x2fab, 0xa0b0, 0x32d0, 0x36e5,
0x316f, 0xb43b, 0xacd8, 0xabf8, 0xb529, 0xb357, 0x2548, 0x3796,
0xb0c6, 0x3119, 0xb6b1, 0xb310, 0xb553, 0x2d03, 0x348c, 0x2efd,
0x2c78, 0xaaf9, 0xa4b6, 0x2cfc, 0x3304, 0x3198, 0x32fe, 0x32aa,
0xab63, 0xb36a, 0xb2d1, 0xb198, 0xae66, 0x2d32, 0xb0d0, 0xb72c,
0x3268, 0x254d, 0xb3fb, 0x2d16, 0x32e9, 0x36a6, 0xb5ea, 0x1f3c,
0xb84b, 0xaeca, 0xacc4, 0x2d9a, 0x3859, 0xadd2, 0xb251, 0xb73c,
0x3074, 0x2b00, 0xb464, 0xb0eb, 0xb756, 0xb11b, 0xa357, 0xb071,
0xb493, 0x3150, 0x9fb3, 0xb49b, 0x2932, 0x263b, 0xb9b2, 0xaf27,
0x2fec, 0xb67c, 0xb4a9, 0x314e, 0xb640, 0x28da, 0x2c4c, 0xa54c,
0x3784, 0xb44c, 0xb5da, 0x35c0, 0xb59f, 0x1b4c, 0xab26, 0x31ec,
0x330f, 0x308f, 0xb039, 0xa924, 0x3573, 0xb718, 0xb809, 0xb09a,
0xb32f, 0x369f, 0xb4e0, 0xb85e, 0x34c7, 0xacd4, 0xb65a, 0xb9a6,
0xb539, 0x271f, 0xac52, 0x303c, 0xafa4, 0x36ad, 0xaad2, 0x32e6,
0x3871, 0x303d, 0xaf2c, 0xb702, 0xabef, 0x36ba, 0xb817, 0xb16c,
0x374b, 0xa8c0, 0x2e3b, 0xb815, 0x2815, 0x373b, 0x9e10, 0x382e,
0xba5c, 0xac08, 0xb653, 0x29c2, 0x3706, 0x30dc, 0x3c00, 0x30db,
0x2e27, 0xad11, 0xb1d3, 0x361a, 0x35ee, 0xb201, 0x31db, 0xb8b5,
0xaf96, 0x3269, 0x2fb6, 0x36c8, 0xb7b9, 0x2c75, 0x31be, 0xac3c,
0x2980, 0xaece, 0xb005, 0xb76e, 0x303d, 0xb279, 0xb9a2, 0xb01b,
0x36ff, 0x3122, 0xaf2b, 0xa8f4
};
static const uint16_t in_com2[300] = {
0x31cf, 0x316f, 0x339d, 0x347e, 0x2f20, 0x3482, 0x36d4, 0x30b6,
0x34d2, 0x2d71, 0x2e32, 0x2f93, 0x26c4, 0x2ec8, 0x3696, 0x305e,
0x355e, 0x3277, 0x35c8, 0x37a9, 0x3870, 0x39ce, 0x365e, 0x2d39,
0x3604, 0x38f6, 0x2890, 0x29d7, 0x3165, 0x3173, 0x2cee, 0x315b,
0x320e, 0x353d, 0x3005, 0x34d6, 0x3530, 0x2f6b, 0x25fd, 0x32d5,
0x33ff, 0x335f, 0x2aaf, 0x2f94, 0x339d, 0x315a, 0x3801, 0x3656,
0x349a, 0x35d3, 0x3493, 0x34c8, 0x3626, 0x32e0, 0x341b, 0x3703,
0x2b5b, 0x2e59, 0x3566, 0x38d2, 0x1bb4, 0x3454, 0x35a1, 0x3479,
0x35da, 0x3046, 0x2baa, 0x3495, 0x33e4, 0x317f, 0x3577, 0x264f,
0x321d, 0x2e04, 0x2cf3, 0x3908, 0x2b4e, 0x1c56, 0x399f, 0x2c7c,
0x300b, 0x2f4f, 0x3195, 0x352c, 0x36b8, 0x2df0, 0x25f4, 0x316a,
0x2f32, 0x383d, 0x2b6b, 0x2e5f, 0x33fc, 0x3113, 0x3714, 0x3603,
0x3434, 0x2c5b, 0x356a, 0x3114, 0x34af, 0x3416, 0x313b, 0x3924,
0x34dc, 0x34a5, 0x3079, 0x3841, 0x2efd, 0x2a88, 0x3ac5, 0x35ee,
0x3330, 0x2d9e, 0x29b6, 0x31a5, 0x2b03, 0x3572, 0x3702, 0x3561,
0x3446, 0x2c6c, 0x2b88, 0x354e, 0x27a9, 0x38df, 0x3408, 0x2fdc,
0x3635, 0x2f30, 0x3685, 0x3511, 0x2cec, 0x34cc, 0x2fe8, 0x3314,
0x2229, 0x3548, 0x2992, 0x3a52, 0x2fab, 0x20b0, 0x32d0, 0x36e5,
0x316f, 0x343b, 0x2cd8, 0x2bf8, 0x3529, 0x3357, 0x2548, 0x3796,
0x30c6, 0x3119, 0x36b1, 0x3310, 0x3553, 0x2d03, 0x348c, 0x2efd,
0x2c78, 0x2af9, 0x24b6, 0x2cfc, 0x3304, 0x3198, 0x32fe, 0x32aa,
0x2b63, 0x336a, 0x32d1, 0x3198, 0x2e66, 0x2d32, 0x30d0, 0x372c,
0x3268, 0x254d, 0x33fb, 0x2d16, 0x32e9, 0x36a6, 0x35ea, 0x1f3c,
0x384b, 0x2eca, 0x2cc4, 0x2d9a, 0x3859, 0x2dd2, 0x3251, 0x373c,
0x3074, 0x2b00, 0x3464, 0x30eb, 0x3756, 0x311b, 0x2357, 0x3071,
0x3493, 0x3150, 0x1fb3, 0x349b, 0x2932, 0x263b, 0x39b2, 0x2f27,
0x2fec, 0x367c, 0x34a9, 0x314e, 0x3640, 0x28da, 0x2c4c, 0x254c,
0x3784, 0x344c, 0x35da, 0x35c0, 0x359f, 0x1b4c, 0x2b26, 0x31ec,
0x330f, 0x308f, 0x3039, 0x2924, 0x3573, 0x3718, 0x3809, 0x309a,
0x332f, 0x369f, 0x34e0, 0x385e, 0x34c7, 0x2cd4, 0x365a, 0x39a6,
0x3539, 0x271f, 0x2c52, 0x303c, 0x2fa4, 0x36ad, 0x2ad2, 0x32e6,
0x3871, 0x303d, 0x2f2c, 0x3702, 0x2bef, 0x36ba, 0x3817, 0x316c,
0x374b, 0x28c0, 0x2e3b, 0x3815, 0x2815, 0x373b, 0x1e10, 0x382e,
0x3a5c, 0x2c08, 0x3653, 0x29c2, 0x3706, 0x30dc, 0x3c00, 0x30db,
0x2e27, 0x2d11, 0x31d3, 0x361a, 0x35ee, 0x3201, 0x31db, 0x38b5,
0x2f96, 0x3269, 0x2fb6, 0x36c8, 0x37b9, 0x2c75, 0x31be, 0x2c3c,
0x2980, 0x2ece, 0x3005, 0x376e, 0x303d, 0x3279, 0x39a2, 0x301b,
0x36ff, 0x3122, 0x2f2b, 0x28f4
};
static const uint16_t in_absminmax[300] = {
0xb4f9, 0xac5d, 0x1f97, 0x3a18, 0x3624, 0xa880, 0xb626, 0x3830,
0xb723, 0xb269, 0xb4f6, 0x3057, 0x3160, 0xb08e, 0xb412, 0x9980,
0xb1e3, 0xb844, 0x330f, 0x34fd, 0xb23d, 0x2878, 0xade2, 0x31c9,
0xac10, 0x3384, 0x34d3, 0xb2bc, 0x351f, 0x2ce6, 0xa2d8, 0x3a3c,
0x34d6, 0x2fcb, 0xae62, 0xb34c, 0xb16d, 0xafae, 0xb6bc, 0xb4e7,
0xb49c, 0xb483, 0x3822, 0xb757, 0x31a1, 0x3593, 0x33e9, 0x3237,
0x383b, 0x31fb, 0xb70b, 0xbaf5, 0xb2ef, 0x3747, 0x3125, 0x2a39,
0xb5e3, 0x3706, 0xb46f, 0xb6a5, 0xb4b7, 0xb803, 0xb0ef, 0xb3c8,
0xaaf8, 0x349d, 0x3895, 0xa5d3, 0xac32, 0x183c, 0xb7d1, 0x3304,
0x2c9d, 0xb49c, 0xbbb2, 0x32ff, 0xaf19, 0xb11d, 0xb0ee, 0x36dc,
0xb91f, 0x3687, 0x3a59, 0x3637, 0xb3bc, 0x2cf1, 0xb47c, 0xb120,
0x2b23, 0x33e3, 0x2551, 0x3869, 0xb509, 0x377d, 0x2ac1, 0x33ec,
0xae28, 0x35ab, 0xb2c5, 0x333a, 0xbade, 0x354b, 0xb79a, 0xb606,
0xb4d2, 0xb910, 0x2958, 0xabfe, 0x325b, 0xb443, 0x3207, 0x2d58,
0xb55a, 0x3267, 0x26a5, 0xb427, 0xb498, 0xb5fb, 0x318d, 0x338d,
0x3155, 0xb198, 0x340f, 0xb21d, 0xafce, 0xb6f9, 0xb45c, 0x2804,
0xb704, 0xb02a, 0xb7b3, 0xb40d, 0xa807, 0xba25, 0xb6c6, 0xae83,
0x3786, 0xb598, 0x323a, 0x3790, 0x386e, 0xaf11, 0x2e8b, 0x376c,
0x39b9, 0xb224, 0x2fef, 0x25fa, 0x2a19, 0xb795, 0x2c95, 0x3876,
0xaf52, 0xb64c, 0xb0ac, 0xb39d, 0x3490, 0xaf4e, 0xb482, 0x3900,
0x1f03, 0xb189, 0xb456, 0x302b, 0xb7aa, 0x3260, 0xb84e, 0xb4af,
0x35ba, 0x3809, 0x2eb7, 0x3386, 0xae0a, 0x3417, 0xb6da, 0xae9d,
0x2cec, 0xb01b, 0xb3ed, 0xa218, 0x352f, 0xb819, 0x373e, 0x3830,
0xb2e1, 0x3593, 0xb443, 0x206b, 0xb1cd, 0xb7e4, 0xb568, 0xb8d5,
0xb05a, 0x2ddd, 0x32bb, 0xa77c, 0x38cb, 0xba2d, 0xb314, 0x2cf3,
0xae77, 0x380e, 0x2b0f, 0x35e3, 0x37da, 0xb5bd, 0x363f, 0xa360,
0x233f, 0xaccc, 0x39f6, 0x3837, 0x348e, 0xbc00, 0x3723, 0x25f7,
0x3445, 0xb683, 0x3772, 0x3662, 0xb2f8, 0xb095, 0xb825, 0x3836,
0xa30e, 0xac33, 0x316e, 0xb1c6, 0x26a8, 0x390b, 0x3ae4, 0x2e32,
0xb03e, 0x3484, 0xb934, 0xb1eb, 0xb870, 0xad79, 0x380d, 0x33c1,
0x307a, 0xb3df, 0x322b, 0x9e38, 0x378d, 0x2cd7, 0xb372, 0x3749,
0x30e9, 0x247f, 0x36e5, 0xb880, 0x3705, 0xb882, 0xb4b2, 0xb571,
0xaf5c, 0x2b33, 0xb4cf, 0x2db9, 0x3328, 0xba1a, 0x317a, 0xaf15,
0xa3bf, 0xb85f, 0xae2b, 0x3627, 0x309a, 0x30f0, 0xa905, 0xa7c5,
0x3571, 0x334b, 0x36c2, 0x309c, 0xb209, 0x3992, 0x3799, 0xb8d2,
0x3547, 0xb60b, 0xad8e, 0xb037, 0xa8fb, 0xb0c0, 0xb9ac, 0xb4db,
0xb7e5, 0xb3ad, 0x37f1, 0x3455, 0xb83d, 0x3718, 0x340f, 0x2e50,
0xab3e, 0xb7de, 0xb1b0, 0x27a1
};
static const uint16_t in_entropy[75] = {
0x352a, 0x325a, 0x37a9, 0x26b1, 0x2e56, 0x3095, 0x2d7a, 0x2c63,
0x32c2, 0x31cc, 0x31ee, 0x2db3, 0x30ba, 0x2e1c, 0x2937, 0x30c2,
0x303b, 0x3088, 0x2cd1, 0x3023, 0x2f25, 0x2fba, 0x22c7, 0x2bb0,
0x3014, 0x2e0f, 0x2ece, 0x2a25, 0x2a97, 0x3001, 0x2fba, 0x2549,
0x30a0, 0x3817, 0x3582, 0x2f5d, 0x2c5f, 0x3292, 0x3122, 0x2c2e,
0x3014, 0x33f6, 0x20c9, 0x2e70, 0x2e8e, 0x3206, 0x322b, 0x311f,
0x271c, 0x2f32, 0x142f, 0x2f59, 0x2b30, 0x2fd9, 0x314e, 0x3056,
0x24e4, 0x2730, 0x22d5, 0x314b, 0x2ccf, 0x2b3c, 0x1d2e, 0x310a,
0x36d2, 0x314a, 0x3689, 0x245a, 0x34be, 0x1deb, 0x2cea, 0x3327,
0x2b1f, 0x331b, 0x2e95
};
static const uint16_t in_entropy_dim[11] = {
0x000A, 0x0003, 0x0008, 0x0009, 0x000C, 0x0003, 0x0008, 0x0009,
0x000C, 0x0003, 0x0008
};
static const uint16_t in_logsumexp[75] = {
0x379c, 0x3452, 0x3412, 0x2b0c, 0x327a, 0x2ff4, 0x29ee, 0x31ba,
0x2d0d, 0x2f26, 0x327a, 0x31fd, 0x30f1, 0x2af2, 0x2fe1, 0x2e62,
0x221f, 0x3156, 0x2da8, 0x2f50, 0x2c89, 0x2f91, 0x2b5e, 0x3096,
0x27ff, 0x316c, 0x29d8, 0x3179, 0x21f9, 0x2986, 0x2b4c, 0x2d2f,
0x34d4, 0x3602, 0x352a, 0x2c78, 0x3380, 0x3209, 0x337b, 0x2db7,
0x2503, 0x2cd0, 0x2dba, 0x2f74, 0x2f20, 0x32e4, 0x2faa, 0x2b82,
0x328e, 0x20db, 0x3114, 0x1d9e, 0x306a, 0x30ef, 0x201d, 0x2929,
0x28e6, 0x2d4c, 0x29e9, 0x2f9c, 0x2860, 0x2dcc, 0x3101, 0x2de8,
0x38a0, 0x2a4e, 0x35f6, 0x259e, 0x2b9f, 0x3071, 0x3310, 0x2bff,
0x3273, 0x2d9e, 0x32a2
};
static const uint16_t in_logsumexp_dim[11] = {
0x000A, 0x0003, 0x0008, 0x0009, 0x000C, 0x0003, 0x0008, 0x0009,
0x000C, 0x0003, 0x0008
};
static const uint16_t in_kl1[75] = {
0x2c39, 0x2781, 0x3b3d, 0x2b10, 0x32bc, 0x30be, 0x3213, 0x28fb,
0x306f, 0x25d6, 0x3247, 0x2cea, 0x212d, 0x3312, 0x3027, 0x2e57,
0x305f, 0x336e, 0x235e, 0x2d22, 0x1c70, 0x2d59, 0x2d28, 0x2f89,
0x3133, 0x2507, 0x2cd3, 0x30a2, 0x2c27, 0x302d, 0x26c3, 0x2dbe,
0x3588, 0x3497, 0x35e1, 0x2e5c, 0x2d3e, 0x2cce, 0x31bc, 0x3058,
0x2c95, 0x3197, 0x31d6, 0x2c4c, 0x2c93, 0x301b, 0x3308, 0x2eb2,
0x30a5, 0x215f, 0x3153, 0x2d8a, 0x304b, 0x1f79, 0x2c88, 0x2eb1,
0x2fa6, 0x2efd, 0x2c89, 0x2ab7, 0x22d7, 0x2c4a, 0x308c, 0x2ef5,
0x31d4, 0x35c2, 0x3754, 0x3154, 0x3229, 0x312e, 0x31dc, 0x28fa,
0x2ea2, 0x2ea0, 0x2a68
};
static const uint16_t in_kl2[75] = {
0x3521, 0x3264, 0x37ad, 0x2e8b, 0x2eba, 0x3271, 0x3040, 0x2dab,
0x2b80, 0x33ff, 0x2bdd, 0x2c8e, 0x2ee3, 0x2b55, 0x2ec2, 0x30dd,
0x2e9d, 0x2a4e, 0x330e, 0x3044, 0x2ec1, 0x2d61, 0x3066, 0x27c0,
0x2a3b, 0x3011, 0x29e6, 0x2c3c, 0x2c53, 0x2e40, 0x2c9c, 0x2f83,
0x3740, 0x2d3f, 0x3770, 0x2ac1, 0x3038, 0x2b63, 0x30e3, 0x32be,
0x28fa, 0x343e, 0x2dc8, 0x30eb, 0x2b69, 0x2b4c, 0x2c8e, 0x3430,
0x23b3, 0x2d39, 0x3434, 0x2902, 0x3106, 0x2e18, 0x2677, 0x28c7,
0x2d5d, 0x2eaf, 0x2d9b, 0x2f4f, 0x2b32, 0x1c82, 0x2e1c, 0x3074,
0x34b7, 0x344c, 0x36fd, 0x20d6, 0x2d3b, 0x3163, 0x30c1, 0x305f,
0x28ad, 0x340d, 0x314e
};
static const uint16_t in_kl_dim[11] = {
0x000A, 0x0003, 0x0008, 0x0009, 0x000C, 0x0003, 0x0008, 0x0009,
0x000C, 0x0003, 0x0008
};
static const uint16_t in_logsumexp_dp1[75] = {
0xbbac, 0xb95d, 0xc077, 0xbd8d, 0xc454, 0xbf3a, 0xc180, 0xbf67,
0xbe72, 0xc2fc, 0xc01a, 0xc0d1, 0xc117, 0xc0e6, 0xbf32, 0xbeed,
0xbed7, 0xc456, 0xc083, 0xc062, 0xbfc1, 0xc0dc, 0xc46b, 0xc0d5,
0xc114, 0xc29d, 0xc2b7, 0xc0a2, 0xc08b, 0xc0c6, 0xc04f, 0xc048,
0xbea1, 0xb929, 0xbcff, 0xbe6a, 0xc144, 0xbf58, 0xc0b7, 0xc2a6,
0xbe98, 0xc013, 0xc038, 0xbcc8, 0xc152, 0xbfec, 0xc053, 0xbf2d,
0xc07e, 0xc0d1, 0xc3e8, 0xc6c1, 0xc1c2, 0xc050, 0xc152, 0xc053,
0xc211, 0xc031, 0xc405, 0xbf61, 0xc18c, 0xc084, 0xc408, 0xc034,
0xbc4b, 0xbb07, 0xbda2, 0xc0d0, 0xbf7e, 0xc00b, 0xbf20, 0xbf14,
0xbf4c, 0xc03d, 0xc48d
};
static const uint16_t in_logsumexp_dp2[75] = {
0xb868, 0xbc58, 0xc0dd, 0xc061, 0xbfaa, 0xbf67, 0xbf2a, 0xbf2f,
0xbf39, 0xc3d4, 0xc138, 0xc195, 0xbea1, 0xc3a3, 0xc02c, 0xbf98,
0xc58e, 0xbf4f, 0xc0b0, 0xbe74, 0xc138, 0xbfc4, 0xc2dc, 0xc30e,
0xc024, 0xbfb4, 0xc2a3, 0xc07a, 0xbef3, 0xc23e, 0xc487, 0xc0e4,
0xc146, 0xbcb5, 0xb798, 0xc211, 0xbf58, 0xbec4, 0xbf39, 0xc14c,
0xc052, 0xc0ec, 0xbee0, 0xc3dc, 0xc140, 0xbe47, 0xbdf8, 0xc028,
0xc0c8, 0xc264, 0xc0f3, 0xbfd4, 0xc1ec, 0xc16f, 0xc12e, 0xc1b4,
0xc1ce, 0xc095, 0xc070, 0xc091, 0xc0a4, 0xc0dd, 0xc07b, 0xc097,
0xb8ba, 0xbce0, 0xbf86, 0xbf82, 0xc10d, 0xbf2b, 0xbf61, 0xbf02,
0xc097, 0xc305, 0xbfb7
};
static const uint16_t in_logsumexp_dp_dim[11] = {
0x000A, 0x0003, 0x0008, 0x0009, 0x000C, 0x0003, 0x0008, 0x0009,
0x000C, 0x0003, 0x0008
};
static const uint16_t ref_max_val[3] = {
0x36d4, 0x36d4, 0x36d4
};
static const uint16_t ref_max_idx[3] = {
0x0006, 0x0006, 0x0006
};
static const uint16_t ref_min_val[3] = {
0xb482, 0xb4d2, 0xb9ce
};
static const uint16_t ref_min_idx[3] = {
0x0005, 0x0008, 0x0015
};
static const uint16_t ref_absmax_val[3] = {
0x3a18, 0x3a18, 0x3a18
};
static const uint16_t ref_absmax_idx[3] = {
0x0003, 0x0003, 0x0003
};
static const uint16_t ref_absmin_val[3] = {
0x1f97, 0x1980, 0x1980
};
static const uint16_t ref_absmin_idx[3] = {
0x0002, 0x000F, 0x000F
};
static const uint16_t ref_mean[4] = {
0x33b9, 0x323d, 0x344c, 0x339c
};
static const uint16_t ref_power[3] = {
0x3789, 0x3a83, 0x40a4
};
static const uint16_t ref_rms[4] = {
0x3427, 0x3338, 0x3515, 0x349c
};
static const uint16_t ref_std[4] = {
0x345c, 0x335e, 0x34e1, 0x34a0
};
static const uint16_t ref_var[4] = {
0x2cc0, 0x2ac9, 0x2df4, 0x2d59
};
static const uint16_t ref_entropy[10] = {
0x3c28, 0x3fc9, 0x4047, 0x40b0, 0x3beb, 0x3f86, 0x3ff6, 0x4063,
0x3c1b, 0x3ee2
};
static const uint16_t ref_logsumexp[10] = {
0x3dc0, 0x406a, 0x409f, 0x4124, 0x3dbb, 0x406a, 0x409f, 0x4124,
0x3dd2, 0x406a
};
static const uint16_t ref_kl[10] = {
0x369e, 0x3651, 0x38a9, 0x3659, 0x31bd, 0x2f26, 0x3821, 0x3534,
0x290c, 0x38a6
};
static const uint16_t ref_logsumexp_dp[10] = {
0xbb45, 0xc000, 0xc084, 0xc0e2, 0xbc28, 0xc02e, 0xc093, 0xc0ed,
0xbc34, 0xc026
};

View file

@ -10,6 +10,7 @@
extern void test_statistics_q7(void);
extern void test_statistics_q15(void);
extern void test_statistics_q31(void);
extern void test_statistics_f16(void);
extern void test_statistics_f32(void);
extern void test_statistics_f64(void);
@ -18,6 +19,9 @@ void test_main(void)
test_statistics_q7();
test_statistics_q15();
test_statistics_q31();
#ifdef CONFIG_CMSIS_DSP_FLOAT16
test_statistics_f16();
#endif
test_statistics_f32();
test_statistics_f64();
}