Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
772 changes: 479 additions & 293 deletions Jenkinsfile

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions lib_voice/lib_build_info.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ set(LIB_COMPILER_FLAGS
-Os
-DHEADROOM_CHECK=0)

if(BUILD_NATIVE)
list(APPEND LIB_COMPILER_FLAGS
-D__xtflm_conf_h_exists__
-DNN_USE_REF
)
endif()
# if(BUILD_NATIVE)
# list(APPEND LIB_COMPILER_FLAGS
# -D__xtflm_conf_h_exists__
# -DNN_USE_REF
# )
# endif()

set(LIB_CXX_SRCS "")
set(lib_ASM_SRCS "")
include(${CMAKE_CURRENT_LIST_DIR}/vnr_model.cmake)
file(RELATIVE_PATH MODEL_OUT_DIR_REL ${CMAKE_CURRENT_LIST_DIR} ${MODEL_OUT_DIR})

Expand Down Expand Up @@ -70,7 +71,7 @@ foreach(target ${APP_BUILD_TARGETS})

# Link aitools with the targets
target_link_libraries(${target} PRIVATE tflite_micro)
if(BUILD_NATIVE)
target_compile_features(${target} PRIVATE cxx_std_11)
endif()
# if(BUILD_NATIVE)
# target_compile_features(${target} PRIVATE cxx_std_11)
# endif()
endforeach()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# python_version 3.11
# pip_version 25.*

xmos-ai-tools==1.4.3.dev24
xmos-ai-tools==1.4.3.dev33
7 changes: 6 additions & 1 deletion tests/lib_aec/aec_unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(aec_unit_tests)

set(APP_HW_TARGET XK-EVK-XU316)
if(DEFINED XCORE_TARGET)
set(APP_HW_TARGET ${XCORE_TARGET})
else()
set(APP_HW_TARGET XK-EVK-XU316)
endif()

set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../)
include(${XMOS_SANDBOX_DIR}/lib_voice/tests/etc/build_options.cmake)

Expand Down
31 changes: 25 additions & 6 deletions tests/lib_aec/aec_unit_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Copyright 2021-2026 XMOS LIMITED.
# This Software is subject to the terms of the XMOS Public Licence: Version 1.
from builtins import str
import pytest
import subprocess
import xtagctl

def pytest_addoption(parser):
parser.addoption(
"--arch",
action = "store",
default = "xs3a",
help = "Architecture to run on",
choices = ["xs3a", "vx4b", "sim"],
)

def pytest_collect_file(parent, file_path):
if(file_path.suffix == ".xe"):
Expand All @@ -13,23 +20,35 @@ def pytest_collect_file(parent, file_path):

class UnityTestSource(pytest.File):
def collect(self):
yield UnityTestExecutable.from_parent(self, fspath=self.fspath, name=self.name)
selected_arch = self.config.getoption("arch")
yield UnityTestExecutable.from_parent(
self, fspath=self.fspath, name=self.name, arch=selected_arch
)


class UnityTestExecutable(pytest.Item):
def __init__(self, fspath, name, parent):
def __init__(self, fspath, name, parent, arch):
super(UnityTestExecutable, self).__init__(name, parent)
self.fspath = fspath
self.arch = arch
self._nodeid = self.name # Override the naming to suit C better

def runtest(self):
# Run the binary in the simulator
simulator_fail = False
test_output = None
try:
print("run xrun for executable ", self.fspath)
with xtagctl.acquire("XCORE-AI-EXPLORER") as adapter_id:
test_output = subprocess.check_output(['xrun', '--io', '--adapter-id', adapter_id, self.fspath], text=True, stderr=subprocess.STDOUT)
# NOTE: pytest calls runtest() with no parameters; pass data in via
# config/options during collection and store it on the item.
print(f"run executable {self.fspath} on arch {self.arch}")
if self.arch == "xs3a" or self.arch == "vx4b":
hw_target = "XCORE-AI-EXPLORER" if self.arch == "xs3a" else "XK-EVK-XU416"
with xtagctl.acquire(hw_target) as adapter_id:
test_output = subprocess.check_output(['xrun', '--io', '--adapter-id', adapter_id, self.fspath], text=True, stderr=subprocess.STDOUT)
elif self.arch == "sim":
test_output = subprocess.check_output(['xsim', self.fspath], text=True, stderr=subprocess.STDOUT)
else:
assert 0, f"Architecture {self.arch} not supported"
except subprocess.CalledProcessError as e:
# Unity exits non-zero if an assertion fails
simulator_fail = True
Expand Down
1 change: 1 addition & 0 deletions tests/lib_aec/aec_unit_tests/src/test_calc_coherence.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include "aec_unit_tests.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "aec.h"

Expand Down
1 change: 1 addition & 0 deletions tests/lib_aec/aec_unit_tests/src/test_calc_corr_factor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This Software is subject to the terms of the XMOS Public Licence: Version 1.
#include "aec_unit_tests.h"
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "aec.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,10 @@ void test_compare_filters_and_calc_mu() {
}
}
}
for(int i=0; i<NUM_SHADOW_CHECKPOINTS; i++) {
if(checkpoints[i] != 1) {printf("checkpoint %d not tested\n",i); assert(0);}
// for(int i=0; i<NUM_SHADOW_CHECKPOINTS; i++) {
// if(checkpoints[i] != 1) {printf("checkpoint %d not tested\n",i); assert(0);}
//printf("checkpoints[%d] = %d\n",i, checkpoints[i]);
}
// }
printf("max_diff_coh_mu = %d\n",max_diff_coh_mu);
int fail = 0;
for(int i=0; i<NUM_MU_CHECKPOINTS; i++) {
Expand Down
2 changes: 1 addition & 1 deletion tests/lib_aec/aec_unit_tests/src/test_l2_unify_exponent.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void test_bfp_s32_l2_unify_exponent() {
int min_reqd_headroom[NUM_SUBGROUPS];
int null_mapping; //null_mapping = 1 => unify everything without looking at subgroups
//null_mapping = 0 => unify according to subgroups
for(int iter=0; iter<1<<12; iter++) {
for(int iter=0; iter<(1<<12)/F; iter++) {
null_mapping = pseudo_rand_uint32(&seed) % 2;
for(int i=0; i<NUM_SUBGROUPS; i++) {
remaining_length[i] = LENGTH_PER_SUBGROUP;
Expand Down
7 changes: 6 additions & 1 deletion tests/lib_aec/test_aec_schedule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(test_aec_schedule)

set(APP_HW_TARGET XK-EVK-XU316)
if(DEFINED XCORE_TARGET)
set(APP_HW_TARGET ${XCORE_TARGET})
else()
set(APP_HW_TARGET XK-EVK-XU316)
endif()

set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../..)

set(CONFIG_XSCOPE_PATH ${XMOS_SANDBOX_DIR}/lib_voice/tests/shared/file_utils)
Expand Down
16 changes: 16 additions & 0 deletions tests/lib_aec/test_aec_schedule/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

def pytest_addoption(parser):
parser.addoption(
"--arch",
nargs = "+",
default = ["xs3a"],
help = "One or more architectures to run on (e.g. --arch xs3a sim)",
choices = ["xs3a", "vx4b"],
)

def pytest_generate_tests(metafunc):
if "target" in metafunc.fixturenames:
selected_arches = metafunc.config.getoption("arch")
if isinstance(selected_arches, str):
selected_arches = [selected_arches]
metafunc.parametrize("target", selected_arches)
16 changes: 16 additions & 0 deletions tests/lib_aec/test_aec_schedule/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

#include "voice.h"
#include <fileio.h>
#include <xcore/chanend.h>
#if TEST_WAV_XSCOPE
#include "xscope_io_device.h"
#endif

extern aec_task_distribution_t tdist;
void test_aec(int32_t (*input)[AEC_FRAME_ADVANCE],
Expand Down Expand Up @@ -49,3 +53,15 @@ void wrapper_task(const char *input_file_name, const char *output_file_name)
file_close(&output_file);
shutdown_session();
}

int main() {
#if TEST_WAV_XSCOPE
chanend_t xscope_chan = chanend_alloc();
xscope_io_init(xscope_chan);
#endif
wrapper_task("input.bin", "output.bin");
#if TEST_WAV_XSCOPE
chanend_free(xscope_chan);
#endif
return 0;
}
41 changes: 0 additions & 41 deletions tests/lib_aec/test_aec_schedule/src/main.xc

This file was deleted.

6 changes: 3 additions & 3 deletions tests/lib_aec/test_aec_schedule/test_aec_schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from run_dut import run_dut
import numpy as np

def test_aec_schedule():
def test_aec_schedule(target):
one_thread_xe = Path(__file__).parent / "bin" / "aec_std_arch_1thread" / "test_aec_schedule_aec_std_arch_1thread.xe"
two_thread_xe = Path(__file__).parent / "bin" / "aec_std_arch_2threads" / "test_aec_schedule_aec_std_arch_2threads.xe"

Expand All @@ -24,8 +24,8 @@ def test_aec_schedule():
assert input_data.shape[0] == 4
input_data = pvc.interleave_channel_frames(input_data, 240)

out1, _ = run_dut(input_data, one_thread_xe)
out2, _ = run_dut(input_data, two_thread_xe)
out1, _ = run_dut(input_data, one_thread_xe, target)
out2, _ = run_dut(input_data, two_thread_xe, target)
assert isinstance(out1, np.ndarray) and isinstance(out2, np.ndarray)
assert out1.shape == out2.shape, "Output shapes differ"
assert np.array_equal(out1, out2), "Outputs differ between 1-thread and 2-thread schedules"
Expand Down
7 changes: 6 additions & 1 deletion tests/lib_agc/test_process_frame/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(test_agc_process_frame)

set(APP_HW_TARGET XK-EVK-XU316)
if(DEFINED XCORE_TARGET)
set(APP_HW_TARGET ${XCORE_TARGET})
else()
set(APP_HW_TARGET XK-EVK-XU316)
endif()

set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../)
include(${XMOS_SANDBOX_DIR}/lib_voice/tests/etc/build_options.cmake)

Expand Down
30 changes: 25 additions & 5 deletions tests/lib_agc/test_process_frame/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
import subprocess
import xtagctl

def pytest_addoption(parser):
parser.addoption(
"--arch",
action = "store",
default = "xs3a",
help = "Architecture to run on",
choices = ["xs3a", "vx4b", "sim"],
)

def pytest_collect_file(parent, file_path):
if(file_path.suffix == ".xe"):
Expand All @@ -12,23 +20,35 @@ def pytest_collect_file(parent, file_path):

class UnityTestSource(pytest.File):
def collect(self):
yield UnityTestExecutable.from_parent(self, fspath=self.fspath, name=self.name)
selected_arch = self.config.getoption("arch")
yield UnityTestExecutable.from_parent(
self, fspath=self.fspath, name=self.name, arch=selected_arch
)


class UnityTestExecutable(pytest.Item):
def __init__(self, fspath, name, parent):
def __init__(self, fspath, name, parent, arch):
super(UnityTestExecutable, self).__init__(name, parent)
self.fspath = fspath
self.arch = arch
self._nodeid = self.name # Override the naming to suit C better

def runtest(self):
# Run the binary in the simulator
simulator_fail = False
test_output = None
try:
print("run xrun for executable ", self.fspath)
with xtagctl.acquire("XCORE-AI-EXPLORER") as adapter_id:
test_output = subprocess.check_output(['xrun', '--io', '--adapter-id', adapter_id, self.fspath], text=True, stderr=subprocess.STDOUT)
# NOTE: pytest calls runtest() with no parameters; pass data in via
# config/options during collection and store it on the item.
print(f"run executable {self.fspath} on arch {self.arch}")
if self.arch == "xs3a" or self.arch == "vx4b":
hw_target = "XCORE-AI-EXPLORER" if self.arch == "xs3a" else "XK-EVK-XU416"
with xtagctl.acquire(hw_target) as adapter_id:
test_output = subprocess.check_output(['xrun', '--io', '--adapter-id', adapter_id, self.fspath], text=True, stderr=subprocess.STDOUT)
elif self.arch == "sim":
test_output = subprocess.check_output(['xsim', self.fspath], text=True, stderr=subprocess.STDOUT)
else:
assert 0, f"Architecture {self.arch} not supported"
except subprocess.CalledProcessError as e:
# Unity exits non-zero if an assertion fails
simulator_fail = True
Expand Down
5 changes: 0 additions & 5 deletions tests/lib_ic/test_calc_vnr_pred/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ file(GLOB APP_C_SRCS
${XMOS_SANDBOX_DIR}/lib_voice/tests/lib_vnr/vnr_unit_tests/src/main.c
${CMAKE_CURRENT_LIST_DIR}/src/*.c)

file(RELATIVE_PATH APP_XC_SRCS
${CMAKE_CURRENT_LIST_DIR}
${XMOS_SANDBOX_DIR}/lib_voice/tests/lib_vnr/vnr_unit_tests/src/main.xc
)

set(APP_INCLUDES
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/../../shared/file_utils/src)
Expand Down
7 changes: 6 additions & 1 deletion tests/lib_ns/ns_unit_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(ns_unit_tests)

set(APP_HW_TARGET XK-EVK-XU316)
if(DEFINED XCORE_TARGET)
set(APP_HW_TARGET ${XCORE_TARGET})
else()
set(APP_HW_TARGET XK-EVK-XU316)
endif()

set(XMOS_SANDBOX_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../../)

include(${CMAKE_CURRENT_LIST_DIR}/../../test_deps.cmake)
Expand Down
Loading