From 8df12f37531d57a10cba2f8b2e8b6a9065202dd5 Mon Sep 17 00:00:00 2001 From: Isabella Gottardi Date: Wed, 7 Apr 2021 17:15:31 +0100 Subject: MLECO-1870: Cherry pick profiling changes from dev to open source repo * Documentation update Change-Id: If85e7ebc44498840b291c408f14e66a5a5faa424 Signed-off-by: Isabella Gottardi --- source/use_case/asr/src/UseCaseHandler.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'source/use_case/asr/src/UseCaseHandler.cc') diff --git a/source/use_case/asr/src/UseCaseHandler.cc b/source/use_case/asr/src/UseCaseHandler.cc index e706eb8..5d3157a 100644 --- a/source/use_case/asr/src/UseCaseHandler.cc +++ b/source/use_case/asr/src/UseCaseHandler.cc @@ -67,6 +67,8 @@ namespace app { auto& platform = ctx.Get("platform"); platform.data_psn->clear(COLOR_BLACK); + auto& profiler = ctx.Get("profiler"); + /* If the request has a valid size, set the audio index. */ if (clipIndex < NUMBER_OF_FILES) { if (!_SetAppCtxClipIdx(ctx, clipIndex)) { @@ -168,18 +170,11 @@ namespace app { info("Inference %zu/%zu\n", audioDataSlider.Index() + 1, static_cast(ceilf(audioDataSlider.FractionalTotalStrides() + 1))); - Profiler prepProfiler{&platform, "pre-processing"}; - prepProfiler.StartProfiling(); - /* Calculate MFCCs, deltas and populate the input tensor. */ prep.Invoke(inferenceWindow, inferenceWindowLen, inputTensor); - 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, model); + arm::app::RunInference(model, profiler); /* Post-process. */ postp.Invoke(outputTensor, reductionAxis, !audioDataSlider.HasNext()); @@ -216,6 +211,8 @@ namespace app { return false; } + profiler.PrintProfilingResult(); + _IncrementAppCtxClipIdx(ctx); } while (runAll && ctx.Get("clipIndex") != startClipIdx); @@ -256,6 +253,8 @@ namespace app { platform.data_psn->set_text_color(COLOR_GREEN); + info("Final results:\n"); + info("Total number of inferences: %zu\n", results.size()); /* Results from multiple inferences should be combined before processing. */ std::vector combinedResults; for (auto& result : results) { @@ -268,8 +267,9 @@ namespace app { for (const auto & result : results) { std::string infResultStr = audio::asr::DecodeOutput(result.m_resultVec); - info("Result for inf %u: %s\n", result.m_inferenceNumber, - infResultStr.c_str()); + info("For timestamp: %f (inference #: %u); label: %s\n", + result.m_timeStamp, result.m_inferenceNumber, + infResultStr.c_str()); } /* Get the decoded result for the combined result. */ @@ -280,7 +280,7 @@ namespace app { dataPsnTxtStartX1, dataPsnTxtStartY1, allow_multiple_lines); - info("Final result: %s\n", finalResultStr.c_str()); + info("Complete recognition: %s\n", finalResultStr.c_str()); return true; } -- cgit v1.2.1