summaryrefslogtreecommitdiff
path: root/source/use_case/kws_asr/src
diff options
context:
space:
mode:
authorIsabella Gottardi <isabella.gottardi@arm.com>2021-04-07 17:15:31 +0100
committerAlexander Efremov <alexander.efremov@arm.com>2021-04-12 14:00:49 +0000
commit8df12f37531d57a10cba2f8b2e8b6a9065202dd5 (patch)
treeba833d15649c3b0f885d57b40d3916970b3fd2c8 /source/use_case/kws_asr/src
parent37ce22ebc9cf3e8529d9914c0eed0f718243d961 (diff)
downloadml-embedded-evaluation-kit-8df12f37531d57a10cba2f8b2e8b6a9065202dd5.tar.gz
MLECO-1870: Cherry pick profiling changes from dev to open source repo
* Documentation update Change-Id: If85e7ebc44498840b291c408f14e66a5a5faa424 Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
Diffstat (limited to 'source/use_case/kws_asr/src')
-rw-r--r--source/use_case/kws_asr/src/MainLoop.cc3
-rw-r--r--source/use_case/kws_asr/src/UseCaseHandler.cc17
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;
}