From 213a543dd0d07b2f8d51a9c7e2055fd99291c960 Mon Sep 17 00:00:00 2001 From: Liam Barry Date: Mon, 9 May 2022 17:06:19 +0100 Subject: MLECO-3186: Each use case should same namespace convention as KWS and ASR Certain UCs required additional work due to case context variables which also became part of a namespace in generated files. Solution was to declare these extra variables as part of the UC namespace in the respective model.hpp files. Additional changes to standardise use of namespaces may be required - proposing new task. Minor typo and rewording of customizing.md in relevant sections included. Signed-off-by: Liam Barry Change-Id: Ie78f82a30be252cb841136ea5115f21fc8d762cb --- source/use_case/ad/src/MainLoop.cc | 27 +++++++++++++-------------- source/use_case/ad/usecase.cmake | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'source/use_case/ad') diff --git a/source/use_case/ad/src/MainLoop.cc b/source/use_case/ad/src/MainLoop.cc index c9d763c..4e5edc1 100644 --- a/source/use_case/ad/src/MainLoop.cc +++ b/source/use_case/ad/src/MainLoop.cc @@ -22,14 +22,15 @@ #include "BufAttributes.hpp" /* Buffer attributes to be applied */ namespace arm { - namespace app { - static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE; - } /* namespace app */ +namespace app { + namespace ad { + extern uint8_t* GetModelPointer(); + extern size_t GetModelLen(); + } /* namespace ad */ + static uint8_t tensorArena[ACTIVATION_BUF_SZ] ACTIVATION_BUF_ATTRIBUTE; +} /* namespace app */ } /* namespace arm */ -extern uint8_t* GetModelPointer(); -extern size_t GetModelLen(); - enum opcodes { MENU_OPT_RUN_INF_NEXT = 1, /* Run on next vector */ @@ -53,7 +54,6 @@ static void DisplayMenu() fflush(stdout); } - void main_loop() { arm::app::AdModel model; /* Model wrapper object. */ @@ -61,9 +61,8 @@ void main_loop() /* Load the model. */ if (!model.Init(arm::app::tensorArena, sizeof(arm::app::tensorArena), - GetModelPointer(), - GetModelLen())) - { + arm::app::ad::GetModelPointer(), + arm::app::ad::GetModelLen())) { printf_err("failed to initialise model\n"); return; } @@ -75,10 +74,10 @@ void main_loop() caseContext.Set("profiler", profiler); caseContext.Set("model", model); caseContext.Set("clipIndex", 0); - caseContext.Set("frameLength", g_FrameLength); - caseContext.Set("frameStride", g_FrameStride); - caseContext.Set("scoreThreshold", g_ScoreThreshold); - caseContext.Set("trainingMean", g_TrainingMean); + caseContext.Set("frameLength", arm::app::ad::g_FrameLength); + caseContext.Set("frameStride", arm::app::ad::g_FrameStride); + caseContext.Set("scoreThreshold", arm::app::ad::g_ScoreThreshold); + caseContext.Set("trainingMean", arm::app::ad::g_TrainingMean); /* Main program loop. */ bool executionSuccessful = true; diff --git a/source/use_case/ad/usecase.cmake b/source/use_case/ad/usecase.cmake index 06d7681..d19820d 100644 --- a/source/use_case/ad/usecase.cmake +++ b/source/use_case/ad/usecase.cmake @@ -86,4 +86,4 @@ generate_tflite_code( MODEL_PATH ${${use_case}_MODEL_TFLITE_PATH} DESTINATION ${SRC_GEN_DIR} EXPRESSIONS ${EXTRA_MODEL_CODE} -) + NAMESPACE "arm" "app" "ad") -- cgit v1.2.1