diff options
Diffstat (limited to 'source/use_case/kws_asr')
-rw-r--r-- | source/use_case/kws_asr/src/MainLoop.cc | 3 | ||||
-rw-r--r-- | source/use_case/kws_asr/src/UseCaseHandler.cc | 17 |
2 files changed, 11 insertions, 9 deletions
diff --git a/source/use_case/kws_asr/src/MainLoop.cc b/source/use_case/kws_asr/src/MainLoop.cc index 37146c9..95e5a8f 100644 --- a/source/use_case/kws_asr/src/MainLoop.cc +++ b/source/use_case/kws_asr/src/MainLoop.cc @@ -101,6 +101,9 @@ void main_loop(hal_platform& platform) /* Instantiate application context. */ arm::app::ApplicationContext caseContext; + arm::app::Profiler profiler{&platform, "kws_asr"}; + caseContext.Set<arm::app::Profiler&>("profiler", profiler); + caseContext.Set<hal_platform&>("platform", platform); caseContext.Set<arm::app::Model&>("kwsmodel", kwsModel); caseContext.Set<arm::app::Model&>("asrmodel", asrModel); diff --git a/source/use_case/kws_asr/src/UseCaseHandler.cc b/source/use_case/kws_asr/src/UseCaseHandler.cc index c50796f..a428210 100644 --- a/source/use_case/kws_asr/src/UseCaseHandler.cc +++ b/source/use_case/kws_asr/src/UseCaseHandler.cc @@ -127,6 +127,7 @@ namespace app { KWSOutput output; + auto& profiler = ctx.Get<Profiler&>("profiler"); auto& kwsModel = ctx.Get<Model&>("kwsmodel"); if (!kwsModel.IsInited()) { printf_err("KWS model has not been initialised\n"); @@ -243,7 +244,7 @@ namespace app { audioDataSlider.TotalStrides() + 1); /* Run inference over this audio clip sliding window. */ - arm::app::RunInference(platform, kwsModel); + arm::app::RunInference(kwsModel, profiler); std::vector<ClassificationResult> kwsClassificationResult; auto& kwsClassifier = ctx.Get<KwsClassifier&>("kwsclassifier"); @@ -284,6 +285,8 @@ namespace app { return output; } + profiler.PrintProfilingResult(); + output.executionSuccess = true; return output; } @@ -300,6 +303,7 @@ namespace app { constexpr uint32_t dataPsnTxtInfStartX = 20; constexpr uint32_t dataPsnTxtInfStartY = 40; + auto& profiler = ctx.Get<Profiler&>("profiler"); auto& platform = ctx.Get<hal_platform&>("platform"); platform.data_psn->clear(COLOR_BLACK); @@ -389,18 +393,11 @@ namespace app { info("Inference %zu/%zu\n", audioDataSlider.Index() + 1, static_cast<size_t>(ceilf(audioDataSlider.FractionalTotalStrides() + 1))); - Profiler prepProfiler{&platform, "pre-processing"}; - prepProfiler.StartProfiling(); - /* Calculate MFCCs, deltas and populate the input tensor. */ asrPrep.Invoke(asrInferenceWindow, asrInferenceWindowLen, asrInputTensor); - prepProfiler.StopProfiling(); - std::string prepProfileResults = prepProfiler.GetResultsAndReset(); - info("%s\n", prepProfileResults.c_str()); - /* Run inference over this audio clip sliding window. */ - arm::app::RunInference(platform, asrModel); + arm::app::RunInference(asrModel, profiler); /* Post-process. */ asrPostp.Invoke(asrOutputTensor, reductionAxis, !audioDataSlider.HasNext()); @@ -432,6 +429,8 @@ namespace app { return false; } + profiler.PrintProfilingResult(); + return true; } |