From 2181d0ac35f30202985a877950c88325ff665f6b Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Wed, 7 Apr 2021 09:27:38 +0100 Subject: 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 Change-Id: Ifde469e3585c37b9a53810236a92ce52d4fbb407 --- tests/use_case/ad/InferenceTestAD.cc | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'tests/use_case/ad/InferenceTestAD.cc') diff --git a/tests/use_case/ad/InferenceTestAD.cc b/tests/use_case/ad/InferenceTestAD.cc index b87699d..d5e21c2 100644 --- a/tests/use_case/ad/InferenceTestAD.cc +++ b/tests/use_case/ad/InferenceTestAD.cc @@ -19,7 +19,7 @@ #include #include "AdModel.hpp" -#include "AdGoldenInput.hpp" +#include "TestData_ad.hpp" #include "hal.h" #include "TensorFlowLiteMicro.hpp" @@ -27,6 +27,8 @@ #define AD_IN_FEATURE_VEC_DATA_SIZE (1024) #endif /* AD_FEATURE_VEC_DATA_SIZE */ +using namespace test; + bool RunInference(arm::app::Model& model, const int8_t vec[]) { TfLiteTensor *inputTensor = model.GetInputTensor(0); @@ -67,7 +69,7 @@ void TestInference(const T *input_goldenFV, const T *output_goldenFV, arm::app:: TfLiteTensor *outputTensor = model.GetOutputTensor(0); REQUIRE(outputTensor); - REQUIRE(outputTensor->bytes == AD_OUT_FEATURE_VEC_DATA_SIZE); + REQUIRE(outputTensor->bytes == OFM_DATA_SIZE); auto tensorData = tflite::GetTensorData(outputTensor); REQUIRE(tensorData); @@ -77,7 +79,7 @@ void TestInference(const T *input_goldenFV, const T *output_goldenFV, arm::app:: } } -TEST_CASE("Running random inference with TensorFlow Lite Micro and AdModel Int8", "[AD][.]") +TEST_CASE("Running random inference with TensorFlow Lite Micro and AdModel Int8", "[AD]") { arm::app::AdModel model{}; @@ -88,13 +90,22 @@ TEST_CASE("Running random inference with TensorFlow Lite Micro and AdModel Int8" REQUIRE(RunInferenceRandom(model)); } -TEST_CASE("Running golden vector inference with TensorFlow Lite Micro and AdModel Int8", "[AD][.]") +TEST_CASE("Running golden vector inference with TensorFlow Lite Micro and AdModel Int8", "[AD]") { - arm::app::AdModel model{}; + for (uint32_t i = 0 ; i < NUMBER_OF_FM_FILES; ++i) { + auto input_goldenFV = get_ifm_data_array(i);; + auto output_goldenFV = get_ofm_data_array(i); - REQUIRE_FALSE(model.IsInited()); - REQUIRE(model.Init()); - REQUIRE(model.IsInited()); + DYNAMIC_SECTION("Executing inference with re-init") + { + arm::app::AdModel model{}; + + REQUIRE_FALSE(model.IsInited()); + REQUIRE(model.Init()); + REQUIRE(model.IsInited()); - TestInference(ad_golden_input, ad_golden_out, model); + TestInference(input_goldenFV, output_goldenFV, model); + + } + } } \ No newline at end of file -- cgit v1.2.1