summaryrefslogtreecommitdiff
path: root/tests/use_case/noise_reduction
diff options
context:
space:
mode:
Diffstat (limited to 'tests/use_case/noise_reduction')
-rw-r--r--tests/use_case/noise_reduction/InferenceTestRNNoise.cc29
-rw-r--r--tests/use_case/noise_reduction/RNNNoiseUCTests.cc54
-rw-r--r--tests/use_case/noise_reduction/RNNoiseModelTests.cc29
3 files changed, 58 insertions, 54 deletions
diff --git a/tests/use_case/noise_reduction/InferenceTestRNNoise.cc b/tests/use_case/noise_reduction/InferenceTestRNNoise.cc
index 9dc640b..fdc59c1 100644
--- a/tests/use_case/noise_reduction/InferenceTestRNNoise.cc
+++ b/tests/use_case/noise_reduction/InferenceTestRNNoise.cc
@@ -23,16 +23,17 @@
#include <random>
namespace arm {
- namespace app {
- static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE;
- } /* namespace app */
+namespace app {
+ static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE;
+ namespace rnn {
+ extern uint8_t* GetModelPointer();
+ extern size_t GetModelLen();
+ } /* namespace rnn */
+} /* namespace app */
} /* namespace arm */
-extern uint8_t* GetModelPointer();
-extern size_t GetModelLen();
-
namespace test {
-namespace rnnoise {
+namespace noise_reduction {
bool RunInference(arm::app::Model& model, const std::vector<std::vector<int8_t>> inData)
{
@@ -73,9 +74,9 @@ namespace rnnoise {
REQUIRE_FALSE(model.IsInited());
REQUIRE(model.Init(arm::app::tensorArena,
- sizeof(arm::app::tensorArena),
- GetModelPointer(),
- GetModelLen()));
+ sizeof(arm::app::tensorArena),
+ arm::app::rnn::GetModelPointer(),
+ arm::app::rnn::GetModelLen()));
REQUIRE(model.IsInited());
REQUIRE(RunInferenceRandom(model));
@@ -135,14 +136,14 @@ namespace rnnoise {
REQUIRE_FALSE(model.IsInited());
REQUIRE(model.Init(arm::app::tensorArena,
- sizeof(arm::app::tensorArena),
- GetModelPointer(),
- GetModelLen()));
+ sizeof(arm::app::tensorArena),
+ arm::app::rnn::GetModelPointer(),
+ arm::app::rnn::GetModelLen()));
REQUIRE(model.IsInited());
TestInference<int8_t>(goldenInputFV, goldenOutputFV, model);
}
}
-} /* namespace rnnoise */
+} /* namespace noise_reduction */
} /* namespace test */
diff --git a/tests/use_case/noise_reduction/RNNNoiseUCTests.cc b/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
index bebfdfd..310814f 100644
--- a/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
+++ b/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
@@ -25,14 +25,15 @@
#include <Profiler.hpp>
namespace arm {
- namespace app {
- static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE;
- } /* namespace app */
+namespace app {
+ static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE;
+ namespace rnn {
+ extern uint8_t* GetModelPointer();
+ extern size_t GetModelLen();
+ } /* namespace rnn */
+} /* namespace app */
} /* namespace arm */
-extern uint8_t* GetModelPointer();
-extern size_t GetModelLen();
-
#define PLATFORM hal_platform_init();
#define CONTEXT \
@@ -48,9 +49,9 @@ TEST_CASE("Verify output tensor memory dump")
arm::app::RNNoiseModel model{};
REQUIRE(model.Init(arm::app::tensorArena,
- sizeof(arm::app::tensorArena),
- GetModelPointer(),
- GetModelLen()));
+ sizeof(arm::app::tensorArena),
+ arm::app::rnn::GetModelPointer(),
+ arm::app::rnn::GetModelLen()));
REQUIRE(model.IsInited());
/* Populate the output tensors */
@@ -112,15 +113,15 @@ TEST_CASE("Inference run all clips", "[RNNoise]")
CONTEXT
caseContext.Set<uint32_t>("clipIndex", 0);
- caseContext.Set<uint32_t>("numInputFeatures", g_NumInputFeatures);
- caseContext.Set<uint32_t>("frameLength", g_FrameLength);
- caseContext.Set<uint32_t>("frameStride", g_FrameStride);
+ caseContext.Set<uint32_t>("numInputFeatures", arm::app::rnn::g_NumInputFeatures);
+ caseContext.Set<uint32_t>("frameLength", arm::app::rnn::g_FrameLength);
+ caseContext.Set<uint32_t>("frameStride", arm::app::rnn::g_FrameStride);
/* Load the model. */
REQUIRE(model.Init(arm::app::tensorArena,
- sizeof(arm::app::tensorArena),
- GetModelPointer(),
- GetModelLen()));
+ sizeof(arm::app::tensorArena),
+ arm::app::rnn::GetModelPointer(),
+ arm::app::rnn::GetModelLen()));
REQUIRE(arm::app::NoiseReductionHandler(caseContext, true));
}
@@ -147,22 +148,22 @@ void testInfByIndex(std::vector<uint32_t>& numberOfInferences) {
caseContext.Set<std::function<const int16_t*(const uint32_t)>>("features", get_audio_array);
caseContext.Set<std::function<const char* (const uint32_t)>>("featureFileNames", get_test_filename);
- caseContext.Set<uint32_t>("frameLength", g_FrameLength);
- caseContext.Set<uint32_t>("frameStride", g_FrameStride);
- caseContext.Set<uint32_t>("numInputFeatures", g_NumInputFeatures);
+ caseContext.Set<uint32_t>("frameLength", arm::app::rnn::g_FrameLength);
+ caseContext.Set<uint32_t>("frameStride", arm::app::rnn::g_FrameStride);
+ caseContext.Set<uint32_t>("numInputFeatures", arm::app::rnn::g_NumInputFeatures);
/* Load the model. */
REQUIRE(model.Init(arm::app::tensorArena,
- sizeof(arm::app::tensorArena),
- GetModelPointer(),
- GetModelLen()));
+ sizeof(arm::app::tensorArena),
+ arm::app::rnn::GetModelPointer(),
+ arm::app::rnn::GetModelLen()));
- size_t oneInferenceOutSizeBytes = g_FrameLength * sizeof(int16_t);
+ size_t oneInferenceOutSizeBytes = arm::app::rnn::g_FrameLength * sizeof(int16_t);
auto infIndex = 0;
for (auto numInf: numberOfInferences) {
DYNAMIC_SECTION("Number of features: "<< numInf) {
caseContext.Set<uint32_t>("clipIndex", 1); /* Only getting p232_208.wav for tests. */
- uint32_t audioSizeInput = numInf*g_FrameLength;
+ uint32_t audioSizeInput = numInf * arm::app::rnn::g_FrameLength;
caseContext.Set<std::function<uint32_t(const uint32_t)>>("featureSizes",
get_golden_input_p232_208_array_size(audioSizeInput));
@@ -180,12 +181,13 @@ void testInfByIndex(std::vector<uint32_t>& numberOfInferences) {
REQUIRE(arm::app::NoiseReductionHandler(caseContext, false));
/* The expected output after post-processing. */
- std::vector<int16_t> golden(&ofms[infIndex][0], &ofms[infIndex][0] + g_FrameLength);
+ std::vector<int16_t> golden(&ofms[infIndex][0],
+ &ofms[infIndex][0] + arm::app::rnn::g_FrameLength);
size_t startOfLastInfOut = undefMemDumpBytesWritten - oneInferenceOutSizeBytes;
/* The actual result from the usecase handler. */
- std::vector<int16_t> runtime(g_FrameLength);
+ std::vector<int16_t> runtime(arm::app::rnn::g_FrameLength);
std::memcpy(runtime.data(), &memDump[startOfLastInfOut], oneInferenceOutSizeBytes);
/* Margin of 43 is 0.07% error. */
@@ -211,7 +213,7 @@ TEST_CASE("Inference by index - several inferences", "[RNNoise]")
REQUIRE(64757 == totalAudioSize); /* Checking that the input file is as expected and has not changed. */
/* 3 different inference amounts: 1, 2 and all inferences required to cover total feature set */
- uint32_t totalInferences = totalAudioSize / g_FrameLength;
+ uint32_t totalInferences = totalAudioSize / arm::app::rnn::g_FrameLength;
std::vector<uint32_t> numberOfInferences = {1, 2, totalInferences};
testInfByIndex(numberOfInferences);
}
diff --git a/tests/use_case/noise_reduction/RNNoiseModelTests.cc b/tests/use_case/noise_reduction/RNNoiseModelTests.cc
index 9720ba5..7bd83b1 100644
--- a/tests/use_case/noise_reduction/RNNoiseModelTests.cc
+++ b/tests/use_case/noise_reduction/RNNoiseModelTests.cc
@@ -23,14 +23,15 @@
#include <random>
namespace arm {
- namespace app {
- static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE;
- } /* namespace app */
+namespace app {
+ static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE;
+ namespace rnn {
+ extern uint8_t* GetModelPointer();
+ extern size_t GetModelLen();
+ } /* namespace rnn */
+} /* namespace app */
} /* namespace arm */
-extern uint8_t* GetModelPointer();
-extern size_t GetModelLen();
-
bool RunInference(arm::app::Model& model, std::vector<int8_t> vec,
const size_t sizeRequired, const size_t dataInputIndex)
{
@@ -73,8 +74,8 @@ TEST_CASE("Running random inference with TensorFlow Lite Micro and RNNoiseModel
REQUIRE_FALSE(model.IsInited());
REQUIRE(model.Init(arm::app::tensorArena,
sizeof(arm::app::tensorArena),
- GetModelPointer(),
- GetModelLen()));
+ arm::app::rnn::GetModelPointer(),
+ arm::app::rnn::GetModelLen()));
REQUIRE(model.IsInited());
model.ResetGruState();
@@ -128,9 +129,9 @@ TEST_CASE("Test initial GRU out state is 0", "[RNNoise]")
{
TestRNNoiseModel model{};
model.Init(arm::app::tensorArena,
- sizeof(arm::app::tensorArena),
- GetModelPointer(),
- GetModelLen());
+ sizeof(arm::app::tensorArena),
+ arm::app::rnn::GetModelPointer(),
+ arm::app::rnn::GetModelLen());
auto map = model.GetStateMap();
@@ -152,9 +153,9 @@ TEST_CASE("Test GRU state copy", "[RNNoise]")
{
TestRNNoiseModel model{};
model.Init(arm::app::tensorArena,
- sizeof(arm::app::tensorArena),
- GetModelPointer(),
- GetModelLen());
+ sizeof(arm::app::tensorArena),
+ arm::app::rnn::GetModelPointer(),
+ arm::app::rnn::GetModelLen());
REQUIRE(RunInferenceRandom(model, 0));
auto map = model.GetStateMap();