summaryrefslogtreecommitdiff
path: root/tests/use_case/kws_asr
diff options
context:
space:
mode:
authorIsabella Gottardi <isabella.gottardi@arm.com>2021-04-07 09:27:38 +0100
committerIsabella Gottardi <isabella.gottardi@arm.com>2021-05-07 12:19:19 +0100
commit2181d0ac35f30202985a877950c88325ff665f6b (patch)
treee16c50d41d85945e0c2c864323ac1769b02af64f /tests/use_case/kws_asr
parentd580eee180be219e118152cedabc9637da8574d6 (diff)
downloadml-embedded-evaluation-kit-2181d0ac35f30202985a877950c88325ff665f6b.tar.gz
MLECO-1766: Default build flow helper scripts added
MLECO-1882: Anomaly Detection use-case default model download added and tests updated to run with it. Test data generation cmake logic moved from use-case cmakes to top-level cmake script. Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com> Change-Id: Ifde469e3585c37b9a53810236a92ce52d4fbb407
Diffstat (limited to 'tests/use_case/kws_asr')
-rw-r--r--tests/use_case/kws_asr/InferenceTestDSCNN.cc41
-rw-r--r--tests/use_case/kws_asr/InferenceTestWav2Letter.cc4
2 files changed, 18 insertions, 27 deletions
diff --git a/tests/use_case/kws_asr/InferenceTestDSCNN.cc b/tests/use_case/kws_asr/InferenceTestDSCNN.cc
index f0e5c02..e210c33 100644
--- a/tests/use_case/kws_asr/InferenceTestDSCNN.cc
+++ b/tests/use_case/kws_asr/InferenceTestDSCNN.cc
@@ -22,34 +22,32 @@
#include <catch.hpp>
#include <random>
-namespace arm {
-namespace app {
+namespace test {
namespace kws {
-bool RunInference(arm::app::Model& model, const int8_t vec[])
-{
+
+bool RunInference(arm::app::Model& model, const int8_t vec[]) {
TfLiteTensor* inputTensor = model.GetInputTensor(0);
REQUIRE(inputTensor);
const size_t copySz = inputTensor->bytes < IFM_DATA_SIZE ?
- inputTensor->bytes :
- IFM_DATA_SIZE;
+ inputTensor->bytes :
+ IFM_DATA_SIZE;
memcpy(inputTensor->data.data, vec, copySz);
return model.RunInference();
}
-bool RunInferenceRandom(arm::app::Model& model)
-{
+bool RunInferenceRandom(arm::app::Model& model) {
TfLiteTensor* inputTensor = model.GetInputTensor(0);
REQUIRE(inputTensor);
std::random_device rndDevice;
std::mt19937 mersenneGen{rndDevice()};
- std::uniform_int_distribution<short> dist {-128, 127};
+ std::uniform_int_distribution<short> dist{-128, 127};
- auto gen = [&dist, &mersenneGen](){
- return dist(mersenneGen);
- };
+ auto gen = [&dist, &mersenneGen]() {
+ return dist(mersenneGen);
+ };
std::vector<int8_t> randomAudio(inputTensor->bytes);
std::generate(std::begin(randomAudio), std::end(randomAudio), gen);
@@ -59,8 +57,7 @@ bool RunInferenceRandom(arm::app::Model& model)
}
template<typename T>
-void TestInference(const T* input_goldenFV, const T* output_goldenFV, arm::app::Model& model)
-{
+void TestInference(const T* input_goldenFV, const T* output_goldenFV, arm::app::Model& model) {
REQUIRE(RunInference(model, input_goldenFV));
TfLiteTensor* outputTensor = model.GetOutputTensor(0);
@@ -71,12 +68,11 @@ void TestInference(const T* input_goldenFV, const T* output_goldenFV, arm::app::
REQUIRE(tensorData);
for (size_t i = 0; i < outputTensor->bytes; i++) {
- REQUIRE((int)tensorData[i] == (int)((T)output_goldenFV[i]));
+ REQUIRE((int) tensorData[i] == (int) ((T) output_goldenFV[i]));
}
}
-TEST_CASE("Running random inference with Tflu and DsCnnModel Int8", "[DS_CNN]")
-{
+TEST_CASE("Running random inference with Tflu and DsCnnModel Int8", "[DS_CNN]") {
arm::app::DsCnnModel model{};
REQUIRE_FALSE(model.IsInited());
@@ -86,14 +82,12 @@ TEST_CASE("Running random inference with Tflu and DsCnnModel Int8", "[DS_CNN]")
REQUIRE(RunInferenceRandom(model));
}
-TEST_CASE("Running inference with Tflu and DsCnnModel Uint8", "[DS_CNN]")
-{
- for (uint32_t i = 0 ; i < NUMBER_OF_FM_FILES; ++i) {
+TEST_CASE("Running inference with Tflu and DsCnnModel Uint8", "[DS_CNN]") {
+ for (uint32_t i = 0; i < NUMBER_OF_FM_FILES; ++i) {
const int8_t* input_goldenFV = get_ifm_data_array(i);
const int8_t* output_goldenFV = get_ofm_data_array(i);
- DYNAMIC_SECTION("Executing inference with re-init")
- {
+ DYNAMIC_SECTION("Executing inference with re-init") {
arm::app::DsCnnModel model{};
REQUIRE_FALSE(model.IsInited());
@@ -107,5 +101,4 @@ TEST_CASE("Running inference with Tflu and DsCnnModel Uint8", "[DS_CNN]")
}
} //namespace
-} //namespace
-} //namespace
+} //namespace \ No newline at end of file
diff --git a/tests/use_case/kws_asr/InferenceTestWav2Letter.cc b/tests/use_case/kws_asr/InferenceTestWav2Letter.cc
index ee63c2f..897ad0a 100644
--- a/tests/use_case/kws_asr/InferenceTestWav2Letter.cc
+++ b/tests/use_case/kws_asr/InferenceTestWav2Letter.cc
@@ -22,8 +22,7 @@
#include <catch.hpp>
#include <random>
-namespace arm {
-namespace app {
+namespace test {
namespace asr {
bool RunInference(arm::app::Model& model, const int8_t vec[], const size_t copySz)
@@ -111,4 +110,3 @@ TEST_CASE("Running inference with Tflu and Wav2LetterModel Int8", "[Wav2Letter][
} //namespace
} //namespace
-} //namespace