add some code
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "esp_dsp.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dsps_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
TEST_CASE("dsps_dotprod_f32_aexx functionality", "[dsps]")
|
||||
{
|
||||
float check_value = 1235;
|
||||
int max_N = 1024;
|
||||
float *x = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *y = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *z = (float *)memalign(16, max_N * sizeof(float));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
z[0] = check_value;
|
||||
z[2] = check_value + 1;
|
||||
|
||||
for (int i = 1 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_f32(x, y, &z[1], i);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(0, z[1]);
|
||||
}
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 1;
|
||||
y[i] = 3;
|
||||
}
|
||||
for (int i = 1 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_f32(x, y, &z[1], i);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(i * 3, z[1]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_dotprod_f32_aexx benchmark", "[dsps]")
|
||||
{
|
||||
int max_N = 1024;
|
||||
float *x = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *y = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *z = (float *)memalign(16, max_N * sizeof(float));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
printf("Benchmark dsps_dotprod_f32_aexx - x=%8.8"PRIx32", y=%8.8"PRIx32", len=%8.8x\n", (uint32_t)x, (uint32_t)y, 1024);
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
int repeat_count = 1024;
|
||||
for (int i = 0 ; i < repeat_count ; i++) {
|
||||
dsps_dotprod_f32(x, y, &z[1], 1024);
|
||||
}
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float total_b = end_b - start_b;
|
||||
float cycles = total_b / (repeat_count);
|
||||
printf("Benchmark dsps_dotprod_f32_aexx - %f per 1024 samples + overhead.\n", cycles);
|
||||
float min_exec = 1024;
|
||||
float max_exec = 6 * 1024;
|
||||
TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, cycles);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("dsps_dotprod_f32_ansi functionality", "[dsps]")
|
||||
{
|
||||
float check_value = 1235;
|
||||
int max_N = 1024;
|
||||
float *x = (float *)malloc(max_N * sizeof(float));
|
||||
float *y = (float *)malloc(max_N * sizeof(float));
|
||||
float *z = (float *)malloc(max_N * sizeof(float));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
z[0] = check_value;
|
||||
z[2] = check_value + 1;
|
||||
|
||||
for (int i = 1 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_f32_ansi(x, y, &z[1], i);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(0, z[1]);
|
||||
}
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 1;
|
||||
y[i] = 3;
|
||||
}
|
||||
for (int i = 1 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_f32_ansi(x, y, &z[1], i);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(i * 3, z[1]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_dotprod_f32_ansi benchmark", "[dsps]")
|
||||
{
|
||||
int max_N = 1024;
|
||||
float *x = (float *)malloc(max_N * sizeof(float));
|
||||
float *y = (float *)malloc(max_N * sizeof(float));
|
||||
float *z = (float *)malloc(max_N * sizeof(float));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
int repeat_count = 1024;
|
||||
for (int i = 0 ; i < repeat_count ; i++) {
|
||||
dsps_dotprod_f32_ansi(x, y, &z[1], 1024);
|
||||
}
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float total_b = end_b - start_b;
|
||||
float cycles = total_b / (repeat_count);
|
||||
printf("Benchmark dsps_dotprod_f32_ansi - %f per sample + overhead.\n", cycles);
|
||||
float min_exec = 1024;
|
||||
float max_exec = 20 * 1024;
|
||||
TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, cycles);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dsps_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
// Test dsps_dotprod_s16_ansi function
|
||||
TEST_CASE("dsps_dotprod_s16_ansi functionality", "[dsps]")
|
||||
{
|
||||
int16_t check_value = 1235;
|
||||
int max_N = 1024;
|
||||
int16_t *x = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *z = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
z[0] = check_value;
|
||||
z[2] = check_value + 1;
|
||||
|
||||
// Check result == 0
|
||||
for (int i = 4; i < 1024; i++) {
|
||||
esp_err_t status = dsps_dotprod_s16_ansi(x, y, &z[1], i, 0);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(0, z[1]);
|
||||
}
|
||||
|
||||
int16_t val_x = 0x080;
|
||||
int16_t val_y = 0x100;
|
||||
int16_t val_shift = 0;
|
||||
|
||||
for (int i = 0; i < max_N; i++) {
|
||||
x[i] = val_x;
|
||||
y[i] = val_y;
|
||||
}
|
||||
|
||||
// We check that dotproduct working with shift = 0;
|
||||
for (int i = 4 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_s16_ansi(x, y, &z[1], i, val_shift);
|
||||
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL((i * (val_x * val_y) + (0x7fff >> val_shift)) >> (15 - val_shift), z[1]);
|
||||
}
|
||||
val_shift = 2;
|
||||
for (int i = 4 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_s16_ansi(x, y, &z[1], i, val_shift);
|
||||
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(((long long)i * ((long long)val_x * (long long)val_y) + ((long long)0x7fff >> val_shift)) >> (15 - val_shift), z[1]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
// Test dsps_dotprod_s16_ansi function
|
||||
TEST_CASE("dsps_dotprod_s16_aexx functionality", "[dsps]")
|
||||
{
|
||||
int16_t check_value = 1235;
|
||||
int max_N = 1024;
|
||||
int16_t *x = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *z = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
z[0] = check_value;
|
||||
z[2] = check_value + 1;
|
||||
|
||||
// Check result == 0
|
||||
for (int i = 4 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_s16(x, y, &z[1], i, 0);
|
||||
{
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(0, z[1]);
|
||||
}
|
||||
}
|
||||
|
||||
int16_t val_x = 0x080;
|
||||
int16_t val_y = 0x100;
|
||||
int16_t val_shift = 0;
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = val_x;
|
||||
y[i] = val_y;
|
||||
}
|
||||
// We check that dotproduct working with shift = 0;
|
||||
for (int i = 4 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_s16(x, y, &z[1], i, val_shift);
|
||||
{
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL((i * (val_x * val_y) + (0x7fff >> val_shift)) >> (15 - val_shift), z[1]);
|
||||
}
|
||||
}
|
||||
val_shift = 2;
|
||||
for (int i = 4 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprod_s16(x, y, &z[1], i, val_shift);
|
||||
{
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL((i * (val_x * val_y) + ((int)0x7fff >> val_shift)) >> (15 - val_shift), z[1]);
|
||||
}
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
static portMUX_TYPE testnlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
TEST_CASE("dsps_dotprod_s16 benchmark", "[dsps]")
|
||||
{
|
||||
int max_N = 1024;
|
||||
|
||||
int16_t *x = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *z = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0x100;
|
||||
y[i] = 0x200;
|
||||
}
|
||||
// Disable interrupt to get exect count
|
||||
|
||||
portENTER_CRITICAL(&testnlock);
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
int repeat_count = 1024;
|
||||
for (int i = 0 ; i < repeat_count ; i++) {
|
||||
dsps_dotprod_s16(x, y, &z[1], 1024, 0);
|
||||
}
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
portEXIT_CRITICAL(&testnlock);
|
||||
|
||||
float total_b = end_b - start_b;
|
||||
float cycles = total_b / (repeat_count);
|
||||
printf("Benchmark dsps_dotprod_s16 - %f cycles for 1024 samples + overhead. Result = %08x\n", cycles, z[1]);
|
||||
float min_exec = 256;
|
||||
float max_exec = 8 * 1024;
|
||||
TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, cycles);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_dotprod_s16_ansi benchmark", "[dsps]")
|
||||
{
|
||||
int max_N = 1024;
|
||||
|
||||
int16_t *x = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *z = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0x100;
|
||||
y[i] = 0x200;
|
||||
}
|
||||
// Disable interrupt to get exect count
|
||||
|
||||
portENTER_CRITICAL(&testnlock);
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
int repeat_count = 1024;
|
||||
for (int i = 0 ; i < repeat_count ; i++) {
|
||||
dsps_dotprod_s16_ansi(x, y, &z[1], 1024, 0);
|
||||
}
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
portEXIT_CRITICAL(&testnlock);
|
||||
|
||||
float total_b = end_b - start_b;
|
||||
float cycles = total_b / (repeat_count);
|
||||
printf("Benchmark dsps_dotprod_s16 - %f cycles for 1024 samples + overhead. Result = %08x\n", cycles, z[1]);
|
||||
float min_exec = 1024 * 10;
|
||||
float max_exec = 1024 * 30;
|
||||
TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, cycles);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dsps_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
TEST_CASE("dsps_dotprode_f32 functionality", "[dsps]")
|
||||
{
|
||||
float check_value = 1235;
|
||||
int max_N = 1024;
|
||||
float *x = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *y = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *z = (float *)memalign(16, max_N * sizeof(float));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
z[0] = check_value;
|
||||
z[2] = check_value + 1;
|
||||
|
||||
for (int i = 1 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprode_f32(x, y, &z[1], i, 1, 1);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(0, z[1]);
|
||||
}
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 1;
|
||||
y[i] = 3;
|
||||
}
|
||||
for (int i = 1 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprode_f32(x, y, &z[1], i, 1, 1);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(i * 3, z[1]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_dotprode_f32 benchmark", "[dsps]")
|
||||
{
|
||||
int max_N = 1024;
|
||||
float *x = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *y = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *z = (float *)memalign(16, max_N * sizeof(float));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
int repeat_count = 1024;
|
||||
for (int i = 0 ; i < repeat_count ; i++) {
|
||||
dsps_dotprode_f32(x, y, &z[1], 1024, 1, 1);
|
||||
}
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float total_b = end_b - start_b;
|
||||
float cycles = total_b / (repeat_count);
|
||||
printf("Benchmark dsps_dotprode_f32_aexx - %f per 1024 samples + overhead.\n", cycles);
|
||||
float min_exec = 1024;
|
||||
float max_exec = 6 * 1024;
|
||||
TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, cycles);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("dsps_dotprode_f32_ansi functionality", "[dsps]")
|
||||
{
|
||||
float check_value = 1235;
|
||||
int max_N = 1024;
|
||||
float *x = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *y = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *z = (float *)memalign(16, max_N * sizeof(float));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
z[0] = check_value;
|
||||
z[2] = check_value + 1;
|
||||
|
||||
for (int i = 1 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprode_f32_ansi(x, y, &z[1], i, 1, 1);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(0, z[1]);
|
||||
}
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 1;
|
||||
y[i] = 3;
|
||||
}
|
||||
for (int i = 1 ; i < 1024 ; i++) {
|
||||
esp_err_t status = dsps_dotprode_f32_ansi(x, y, &z[1], i, 1, 1);
|
||||
TEST_ASSERT_EQUAL(status, ESP_OK);
|
||||
TEST_ASSERT_EQUAL(check_value, z[0]);
|
||||
TEST_ASSERT_EQUAL(check_value + 1, z[2]);
|
||||
TEST_ASSERT_EQUAL(i * 3, z[1]);
|
||||
}
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
|
||||
TEST_CASE("dsps_dotprode_f32_ansi benchmark", "[dsps]")
|
||||
{
|
||||
int max_N = 1024;
|
||||
float *x = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *y = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *z = (float *)memalign(16, max_N * sizeof(float));
|
||||
|
||||
for (int i = 0 ; i < max_N ; i++) {
|
||||
x[i] = 0;
|
||||
y[i] = 1000;
|
||||
}
|
||||
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
int repeat_count = 1024;
|
||||
for (int i = 0 ; i < repeat_count ; i++) {
|
||||
dsps_dotprode_f32_ansi(x, y, &z[1], 1024, 1, 1);
|
||||
}
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
|
||||
float total_b = end_b - start_b;
|
||||
float cycles = total_b / (1024 * repeat_count);
|
||||
printf("Benchmark dsps_dotprode_f32_ansi - %f per sample + overhead.\n", cycles);
|
||||
float min_exec = 5;
|
||||
float max_exec = 25;
|
||||
TEST_ASSERT_EXEC_IN_RANGE(min_exec, max_exec, cycles);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_f32_ansi";
|
||||
|
||||
TEST_CASE("dspi_dotprod_f32_ansi functionality", "[dspi]")
|
||||
{
|
||||
float check_value1 = 336;
|
||||
float check_value2 = 480;
|
||||
int max_N = 1024;
|
||||
float *x = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *y = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *z = (float *)memalign(16, max_N * sizeof(float));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 1;
|
||||
y[i] = i % 8 + 1;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
float result = -1;
|
||||
dspi_dotprod_f32_ansi(&image1, &image2, &result, 4, 4);
|
||||
ESP_LOGI(TAG, "result 1 = %f", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_f32_ansi(&image1, &image2, &result, 4, 4);
|
||||
ESP_LOGI(TAG, "result 2 = %f", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_f32_ansi(&image1, &image2, &result, 4, 4);
|
||||
ESP_LOGI(TAG, "result 3 = %f", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_f32_ansi(&image1, &image2, &result, 4, 4);
|
||||
ESP_LOGI(TAG, "result 4 = %f", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_f32_ansi";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_f32_ansi functionality", "[dspi]")
|
||||
{
|
||||
float check_value1 = 976;
|
||||
float check_value2 = 1280;
|
||||
float offset = 10;
|
||||
int max_N = 1024;
|
||||
float *x = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *y = (float *)memalign(16, max_N * sizeof(float));
|
||||
float *z = (float *)memalign(16, max_N * sizeof(float));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 1;
|
||||
y[i] = i % 8 + 1;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
float result = -1;
|
||||
dspi_dotprod_off_f32_ansi(&image1, &image2, &result, 4, 4, offset);
|
||||
ESP_LOGI(TAG, "result 1 = %f", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_f32_ansi(&image1, &image2, &result, 4, 4, offset);
|
||||
ESP_LOGI(TAG, "result 2 = %f", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_off_f32_ansi(&image1, &image2, &result, 4, 4, offset);
|
||||
ESP_LOGI(TAG, "result 3 = %f", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_f32_ansi(&image1, &image2, &result, 4, 4, offset);
|
||||
ESP_LOGI(TAG, "result 4 = %f", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_s16";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_s16_aexx functionality", "[dspi]")
|
||||
{
|
||||
int shift = 2;
|
||||
int16_t offset = 7;
|
||||
|
||||
int max_N = 8192;
|
||||
int16_t *x = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *z = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
|
||||
printf("Data: x=%8.8"PRIx32", y=%8.8"PRIx32", z=%8.8"PRIx32" \n", (uint32_t)x, (uint32_t)y, (uint32_t)z);
|
||||
for (size_t i = 0; i < max_N; i++) {
|
||||
x[i] = i % 7;
|
||||
y[i] = i % 7;
|
||||
z[i] = 0;
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s16 8x8");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64
|
||||
image2d_t image2 = {y, 1, 1, 8, 8, 8, 8}; // Umage 64
|
||||
int16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s16(&image1, &image2, &result, 8, 8, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int16_t result_ref = -1;
|
||||
dspi_dotprod_off_s16_ansi(&image1, &image2, &result_ref, 8, 8, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s16 16x16");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
int16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s16(&image1, &image2, &result, 16, 16, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int16_t result_ref = -1;
|
||||
dspi_dotprod_off_s16_ansi(&image1, &image2, &result_ref, 16, 16, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s16 24x24");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 24, 24, 24, 24}; // Umage 24x24
|
||||
int16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s16(&image1, &image2, &result, 24, 24, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int16_t result_ref = -1;
|
||||
dspi_dotprod_off_s16_ansi(&image1, &image2, &result_ref, 24, 24, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s16 32x32");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 32, 32, 32, 32}; // Umage 32x32
|
||||
int16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s16(&image1, &image2, &result, 32, 32, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int16_t result_ref = -1;
|
||||
dspi_dotprod_off_s16_ansi(&image1, &image2, &result_ref, 32, 32, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s16 done");
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_s16_ansi";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_s16_ansi functionality", "[dspi]")
|
||||
{
|
||||
int16_t check_value1 = 8676;
|
||||
int16_t check_value2 = 8742;
|
||||
int shift = 7;
|
||||
int16_t offset = 11;
|
||||
|
||||
int max_N = 1024;
|
||||
int16_t *x = (int16_t *)malloc(max_N * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)malloc(max_N * sizeof(int16_t));
|
||||
int16_t *z = (int16_t *)malloc(max_N * sizeof(int16_t));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 255;
|
||||
y[i] = i % 8 + 255;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
int16_t result = -1;
|
||||
dspi_dotprod_off_s16_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_s16_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 2 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_off_s16_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 3 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_s16_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 4 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_s8";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_s8_aexx functionality", "[dspi]")
|
||||
{
|
||||
int shift = 2;
|
||||
int8_t offset = 5;
|
||||
|
||||
int max_N = 16384;
|
||||
int8_t *x = (int8_t *)memalign(16, (max_N) * sizeof(int8_t));
|
||||
int8_t *y = (int8_t *)memalign(16, (max_N) * sizeof(int8_t));
|
||||
int8_t *z = (int8_t *)memalign(16, max_N * sizeof(int8_t));
|
||||
|
||||
|
||||
printf("Data: x=%8.8"PRIx32", y=%8.8"PRIx32", z=%8.8"PRIx32" \n", (uint32_t)x, (uint32_t)y, (uint32_t)z);
|
||||
for (size_t i = 0; i < max_N; i++) {
|
||||
x[i] = i % 7;
|
||||
y[i] = i % 7;
|
||||
z[i] = 0;
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s8 16x16");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s8(&image1, &image2, &result, 16, 16, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result_ref, 16, 16, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s8 32x32");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 32, 32, 32, 32}; // Umage 16x16
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s8(&image1, &image2, &result, 32, 32, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result_ref, 32, 32, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s8 48x48");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 48, 48, 48, 48}; // Umage 48x48
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s8(&image1, &image2, &result, 48, 48, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result_ref, 48, 48, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s8 64x64");
|
||||
image2d_t image1 = {&x[3], 1, 1, 128, 128, 128, 128}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 64, 64, 64, 64}; // Umage 32x32
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s8(&image1, &image2, &result, 64, 64, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result_ref, 64, 64, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s8 128x128");
|
||||
image2d_t image1 = {&x[3], 1, 1, 128, 128, 128, 128}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_s8(&image1, &image2, &result, 16, 16, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result_ref, 16, 16, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_s8 done");
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_s8_ansi";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_s8_ansi functionality", "[dspi]")
|
||||
{
|
||||
int8_t check_value1 = 98;
|
||||
int8_t check_value2 = 106;
|
||||
int shift = 7;
|
||||
int8_t offset = 11;
|
||||
|
||||
int max_N = 1024;
|
||||
int8_t *x = (int8_t *)malloc(max_N * sizeof(int8_t));
|
||||
int8_t *y = (int8_t *)malloc(max_N * sizeof(int8_t));
|
||||
int8_t *z = (int8_t *)malloc(max_N * sizeof(int8_t));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 20;
|
||||
y[i] = i % 8 + 20;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
int8_t result = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 2 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 3 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_s8_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 4 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_u16";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_u16_aexx functionality", "[dspi]")
|
||||
{
|
||||
int shift = 2;
|
||||
uint16_t offset = 7;
|
||||
|
||||
int max_N = 8192;
|
||||
uint16_t *x = (uint16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
uint16_t *y = (uint16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
uint16_t *z = (uint16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
|
||||
printf("Data: x=%8.8"PRIx32", y=%8.8"PRIx32", z=%8.8"PRIx32" \n", (uint32_t)x, (uint32_t)y, (uint32_t)z);
|
||||
for (size_t i = 0; i < max_N; i++) {
|
||||
x[i] = i % 7;
|
||||
y[i] = i % 7;
|
||||
z[i] = 0;
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u16 8x8");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64
|
||||
image2d_t image2 = {y, 1, 1, 8, 8, 8, 8}; // Umage 64
|
||||
uint16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u16(&image1, &image2, &result, 8, 8, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint16_t result_ref = -1;
|
||||
dspi_dotprod_off_u16_ansi(&image1, &image2, &result_ref, 8, 8, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u16 16x16");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
uint16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u16(&image1, &image2, &result, 16, 16, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint16_t result_ref = -1;
|
||||
dspi_dotprod_off_u16_ansi(&image1, &image2, &result_ref, 16, 16, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u16 24x24");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 24, 24, 24, 24}; // Umage 24x24
|
||||
uint16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u16(&image1, &image2, &result, 24, 24, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint16_t result_ref = -1;
|
||||
dspi_dotprod_off_u16_ansi(&image1, &image2, &result_ref, 24, 24, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u16 32x32");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 32, 32, 32, 32}; // Umage 32x32
|
||||
uint16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u16(&image1, &image2, &result, 32, 32, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint16_t result_ref = -1;
|
||||
dspi_dotprod_off_u16_ansi(&image1, &image2, &result_ref, 32, 32, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u16 done");
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_u16_ansi";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_u16_ansi functionality", "[dspi]")
|
||||
{
|
||||
uint16_t check_value1 = 8676;
|
||||
uint16_t check_value2 = 8742;
|
||||
int shift = 7;
|
||||
uint16_t offset = 11;
|
||||
|
||||
int max_N = 1024;
|
||||
uint16_t *x = (uint16_t *)malloc(max_N * sizeof(uint16_t));
|
||||
uint16_t *y = (uint16_t *)malloc(max_N * sizeof(uint16_t));
|
||||
uint16_t *z = (uint16_t *)malloc(max_N * sizeof(uint16_t));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 255;
|
||||
y[i] = i % 8 + 255;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
uint16_t result = -1;
|
||||
dspi_dotprod_off_u16_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_u16_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 2 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_off_u16_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 3 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_u16_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 4 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_u8";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_u8_aexx functionality", "[dspi]")
|
||||
{
|
||||
int shift = 2;
|
||||
uint8_t offset = 7;
|
||||
|
||||
int max_N = 16384;
|
||||
uint8_t *x = (uint8_t *)memalign(16, max_N * sizeof(uint8_t));
|
||||
uint8_t *y = (uint8_t *)memalign(16, max_N * sizeof(uint8_t));
|
||||
uint8_t *z = (uint8_t *)memalign(16, max_N * sizeof(uint8_t));
|
||||
|
||||
printf("Data: x=%8.8"PRIx32", y=%8.8"PRIx32", z=%8.8"PRIx32" \n", (uint32_t)x, (uint32_t)y, (uint32_t)z);
|
||||
for (size_t i = 0; i < max_N; i++) {
|
||||
x[i] = i % 7;
|
||||
y[i] = i % 7;
|
||||
z[i] = 0;
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u8 16x16");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u8(&image1, &image2, &result, 16, 16, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result_ref, 16, 16, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u8 32x32");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 32, 32, 32, 32}; // Umage 16x16
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u8(&image1, &image2, &result, 32, 32, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result_ref, 32, 32, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u8 48x48");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 48, 48, 48, 48}; // Umage 48x48
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u8(&image1, &image2, &result, 48, 48, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result_ref, 48, 48, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u8 64x64");
|
||||
image2d_t image1 = {&x[3], 1, 1, 128, 128, 128, 128}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 64, 64, 64, 64}; // Umage 32x32
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u8(&image1, &image2, &result, 64, 64, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result_ref, 64, 64, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u8 128x128");
|
||||
image2d_t image1 = {&x[3], 1, 1, 128, 128, 128, 128}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_off_u8(&image1, &image2, &result, 16, 16, shift, offset);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result_ref, 16, 16, shift, offset);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "dspi_dotprod_off_u8 done");
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_off_u8_ansi";
|
||||
|
||||
TEST_CASE("dspi_dotprod_off_u8_ansi functionality", "[dspi]")
|
||||
{
|
||||
uint8_t check_value1 = 98;
|
||||
uint8_t check_value2 = 106;
|
||||
int shift = 7;
|
||||
uint8_t offset = 11;
|
||||
|
||||
int max_N = 1024;
|
||||
uint8_t *x = (uint8_t *)malloc(max_N * sizeof(uint8_t));
|
||||
uint8_t *y = (uint8_t *)malloc(max_N * sizeof(uint8_t));
|
||||
uint8_t *z = (uint8_t *)malloc(max_N * sizeof(uint8_t));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 20;
|
||||
y[i] = i % 8 + 20;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
uint8_t result = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 2 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 3 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_off_u8_ansi(&image1, &image2, &result, 4, 4, shift, offset);
|
||||
ESP_LOGI(TAG, "result 4 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_s16";
|
||||
|
||||
TEST_CASE("dspi_dotprod_s16_aexx functionality", "[dspi]")
|
||||
{
|
||||
int shift = 2;
|
||||
|
||||
int max_N = 8192;
|
||||
int16_t *x = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
int16_t *z = (int16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
|
||||
printf("Data: x=%8.8"PRIx32", y=%8.8"PRIx32", z=%8.8"PRIx32" \n", (uint32_t)x, (uint32_t)y, (uint32_t)z);
|
||||
for (size_t i = 0; i < max_N; i++) {
|
||||
x[i] = i % 7;
|
||||
y[i] = i % 7;
|
||||
z[i] = 0;
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s16 8x8");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64
|
||||
image2d_t image2 = {y, 1, 1, 8, 8, 8, 8}; // Umage 64
|
||||
int16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s16(&image1, &image2, &result, 8, 8, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int16_t result_ref = -1;
|
||||
dspi_dotprod_s16_ansi(&image1, &image2, &result_ref, 8, 8, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s16 16x16");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
int16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s16(&image1, &image2, &result, 16, 16, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int16_t result_ref = -1;
|
||||
dspi_dotprod_s16_ansi(&image1, &image2, &result_ref, 16, 16, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s16 24x24");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 24, 24, 24, 24}; // Umage 24x24
|
||||
int16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s16(&image1, &image2, &result, 24, 24, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int16_t result_ref = -1;
|
||||
dspi_dotprod_s16_ansi(&image1, &image2, &result_ref, 24, 24, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s16 32x32");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 32, 32, 32, 32}; // Umage 32x32
|
||||
int16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s16(&image1, &image2, &result, 32, 32, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int16_t result_ref = -1;
|
||||
dspi_dotprod_s16_ansi(&image1, &image2, &result_ref, 32, 32, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s16 done");
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_s16_ansi";
|
||||
|
||||
TEST_CASE("dspi_dotprod_s16_ansi functionality", "[dspi]")
|
||||
{
|
||||
int16_t check_value1 = 8321;
|
||||
int16_t check_value2 = 8386;
|
||||
int shift = 7;
|
||||
|
||||
int max_N = 1024;
|
||||
int16_t *x = (int16_t *)malloc(max_N * sizeof(int16_t));
|
||||
int16_t *y = (int16_t *)malloc(max_N * sizeof(int16_t));
|
||||
int16_t *z = (int16_t *)malloc(max_N * sizeof(int16_t));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 255;
|
||||
y[i] = i % 8 + 255;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
int16_t result = -1;
|
||||
dspi_dotprod_s16_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_s16_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 2 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_s16_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 3 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_s16_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 4 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_s8";
|
||||
|
||||
TEST_CASE("dspi_dotprod_s8_aexx functionality", "[dspi]")
|
||||
{
|
||||
int shift = 2;
|
||||
|
||||
int max_N = 16384;
|
||||
int8_t *x = (int8_t *)memalign(16, max_N * sizeof(int8_t));
|
||||
int8_t *y = (int8_t *)memalign(16, max_N * sizeof(int8_t));
|
||||
int8_t *z = (int8_t *)memalign(16, max_N * sizeof(int8_t));
|
||||
|
||||
printf("Data: x=%8.8"PRIx32", y=%8.8"PRIx32", z=%8.8"PRIx32" \n", (uint32_t)x, (uint32_t)y, (uint32_t)z);
|
||||
for (size_t i = 0; i < max_N; i++) {
|
||||
x[i] = i % 7;
|
||||
y[i] = i % 7;
|
||||
z[i] = 0;
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s8 16x16");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s8(&image1, &image2, &result, 16, 16, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result_ref, 16, 16, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s8 32x32");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 32, 32, 32, 32}; // Umage 16x16
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s8(&image1, &image2, &result, 32, 32, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result_ref, 32, 32, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s8 48x48");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 48, 48, 48, 48}; // Umage 48x48
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s8(&image1, &image2, &result, 48, 48, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result_ref, 48, 48, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s8 64x64");
|
||||
image2d_t image1 = {&x[3], 1, 1, 128, 128, 128, 128}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 64, 64, 64, 64}; // Umage 32x32
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s8(&image1, &image2, &result, 64, 64, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result_ref, 64, 64, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s8 128x128");
|
||||
image2d_t image1 = {&x[3], 1, 1, 128, 128, 128, 128}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
int8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_s8(&image1, &image2, &result, 16, 16, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
int8_t result_ref = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result_ref, 16, 16, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "dspi_dotprod_s8 done");
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "";
|
||||
|
||||
TEST_CASE("dspi_dotprod_s8_ansi functionality", "[dspi]")
|
||||
{
|
||||
int8_t check_value1 = 67;
|
||||
int8_t check_value2 = 73;
|
||||
int shift = 7;
|
||||
|
||||
int max_N = 1024;
|
||||
int8_t *x = (int8_t *)malloc(max_N * sizeof(int8_t));
|
||||
int8_t *y = (int8_t *)malloc(max_N * sizeof(int8_t));
|
||||
int8_t *z = (int8_t *)malloc(max_N * sizeof(int8_t));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 20;
|
||||
y[i] = i % 8 + 20;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
int8_t result = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 2 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 3 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_s8_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 4 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_u16";
|
||||
|
||||
TEST_CASE("dspi_dotprod_u16_aexx functionality", "[dspi]")
|
||||
{
|
||||
int shift = 2;
|
||||
|
||||
int max_N = 8192;
|
||||
uint16_t *x = (uint16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
uint16_t *y = (uint16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
uint16_t *z = (uint16_t *)memalign(16, max_N * sizeof(int16_t));
|
||||
|
||||
printf("Data: x=%8.8"PRIx32", y=%8.8"PRIx32", z=%8.8"PRIx32" \n", (uint32_t)x, (uint32_t)y, (uint32_t)z);
|
||||
for (size_t i = 0; i < max_N; i++) {
|
||||
x[i] = i % 7;
|
||||
y[i] = i % 7;
|
||||
z[i] = 0;
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u16 8x8");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64
|
||||
image2d_t image2 = {y, 1, 1, 8, 8, 8, 8}; // Umage 64
|
||||
uint16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u16(&image1, &image2, &result, 8, 8, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", (end_b - start_b));
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint16_t result_ref = -1;
|
||||
dspi_dotprod_u16_ansi(&image1, &image2, &result_ref, 8, 8, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u16 16x16");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
uint16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u16(&image1, &image2, &result, 16, 16, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint16_t result_ref = -1;
|
||||
dspi_dotprod_u16_ansi(&image1, &image2, &result_ref, 16, 16, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u16 24x24");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 24, 24, 24, 24}; // Umage 24x24
|
||||
uint16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u16(&image1, &image2, &result, 24, 24, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint16_t result_ref = -1;
|
||||
dspi_dotprod_u16_ansi(&image1, &image2, &result_ref, 24, 24, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u16 32x32");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 32, 32, 32, 32}; // Umage 32x32
|
||||
uint16_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u16(&image1, &image2, &result, 32, 32, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint16_t result_ref = -1;
|
||||
dspi_dotprod_u16_ansi(&image1, &image2, &result_ref, 32, 32, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u16 done");
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_u16_ansi";
|
||||
|
||||
TEST_CASE("dspi_dotprod_u16_ansi functionality", "[dspi]")
|
||||
{
|
||||
uint16_t check_value1 = 8321;
|
||||
uint16_t check_value2 = 8386;
|
||||
int shift = 7;
|
||||
|
||||
int max_N = 1024;
|
||||
uint16_t *x = (uint16_t *)malloc(max_N * sizeof(uint16_t));
|
||||
uint16_t *y = (uint16_t *)malloc(max_N * sizeof(uint16_t));
|
||||
uint16_t *z = (uint16_t *)malloc(max_N * sizeof(uint16_t));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 255;
|
||||
y[i] = i % 8 + 255;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
uint16_t result = -1;
|
||||
dspi_dotprod_u16_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_u16_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 2 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_u16_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 3 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_u16_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 4 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
#include <malloc.h>
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "dspi_dotprod_u8";
|
||||
|
||||
TEST_CASE("dspi_dotprod_u8_aexx functionality", "[dspi]")
|
||||
{
|
||||
int shift = 2;
|
||||
|
||||
int max_N = 16384;
|
||||
uint8_t *x = (uint8_t *)memalign(16, max_N * sizeof(uint8_t));
|
||||
uint8_t *y = (uint8_t *)memalign(16, max_N * sizeof(uint8_t));
|
||||
uint8_t *z = (uint8_t *)memalign(16, max_N * sizeof(uint8_t));
|
||||
|
||||
printf("Data: x=%8.8"PRIx32", y=%8.8"PRIx32", z=%8.8"PRIx32" \n", (uint32_t)x, (uint32_t)y, (uint32_t)z);
|
||||
for (size_t i = 0; i < max_N; i++) {
|
||||
x[i] = i % 7;
|
||||
y[i] = i % 7;
|
||||
z[i] = 0;
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u8 16x16");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 16x16
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u8(&image1, &image2, &result, 16, 16, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result_ref, 16, 16, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u8 32x32");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 32, 32, 32, 32}; // Umage 16x16
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u8(&image1, &image2, &result, 32, 32, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result_ref, 32, 32, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u8 48x48");
|
||||
image2d_t image1 = {&x[3], 1, 1, 64, 64, 64, 64}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 48, 48, 48, 48}; // Umage 48x48
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u8(&image1, &image2, &result, 48, 48, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result_ref, 48, 48, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u8 64x64");
|
||||
image2d_t image1 = {&x[3], 1, 1, 128, 128, 128, 128}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 64, 64, 64, 64}; // Umage 32x32
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u8(&image1, &image2, &result, 64, 64, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result_ref, 64, 64, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
{
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u8 128x128");
|
||||
image2d_t image1 = {&x[3], 1, 1, 128, 128, 128, 128}; // Image 64x64
|
||||
image2d_t image2 = {y, 1, 1, 16, 16, 16, 16}; // Umage 8x8
|
||||
uint8_t result = -1;
|
||||
unsigned int start_b = dsp_get_cpu_cycle_count();
|
||||
dspi_dotprod_u8(&image1, &image2, &result, 16, 16, shift);
|
||||
unsigned int end_b = dsp_get_cpu_cycle_count();
|
||||
ESP_LOGI(TAG, "cycles = %i", end_b - start_b);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
uint8_t result_ref = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result_ref, 16, 16, shift);
|
||||
ESP_LOGI(TAG, "result ref = %i", result_ref);
|
||||
TEST_ASSERT_EQUAL( result, result_ref);
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "dspi_dotprod_u8 done");
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <string.h>
|
||||
#include "unity.h"
|
||||
#include "dsp_platform.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dspi_dotprod.h"
|
||||
#include "dsp_tests.h"
|
||||
|
||||
static const char *TAG = "";
|
||||
|
||||
TEST_CASE("dspi_dotprod_u8_ansi functionality", "[dspi]")
|
||||
{
|
||||
uint8_t check_value1 = 67;
|
||||
uint8_t check_value2 = 73;
|
||||
int shift = 7;
|
||||
|
||||
int max_N = 1024;
|
||||
uint8_t *x = (uint8_t *)malloc(max_N * sizeof(uint8_t));
|
||||
uint8_t *y = (uint8_t *)malloc(max_N * sizeof(uint8_t));
|
||||
uint8_t *z = (uint8_t *)malloc(max_N * sizeof(uint8_t));
|
||||
for (size_t i = 0; i < 256; i++) {
|
||||
x[i] = i % 8 + 20;
|
||||
y[i] = i % 8 + 20;
|
||||
z[i] = 0;
|
||||
}
|
||||
image2d_t image1 = {x, 2, 2, 8, 8, 8, 8}; // Image 8x8
|
||||
image2d_t image2 = {y, 2, 2, 8, 8, 8, 8}; // Umage 8x8
|
||||
uint8_t result = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 1 = %i", result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[1];
|
||||
image2.data = &y[1];
|
||||
result = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 2 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
image1.data = &x[image1.stride_x];
|
||||
image2.data = &y[image2.stride_x];
|
||||
result = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 3 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value1);
|
||||
image1.data = &x[image1.stride_x + 1];
|
||||
image2.data = &y[image2.stride_x + 1];
|
||||
result = -1;
|
||||
dspi_dotprod_u8_ansi(&image1, &image2, &result, 4, 4, shift);
|
||||
ESP_LOGI(TAG, "result 4 = %i", (int)result);
|
||||
TEST_ASSERT_EQUAL( result, check_value2);
|
||||
|
||||
free(x);
|
||||
free(y);
|
||||
free(z);
|
||||
}
|
||||
Reference in New Issue
Block a user