summaryrefslogtreecommitdiff
path: root/source/use_case
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2021-05-07 16:08:14 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2021-05-07 17:28:51 +0100
commitf9c19eaa9ab11e4409679fc6d2862c89410493a7 (patch)
treeb791a4c03f1fe986a2ac32593a3dc817ae3f247a /source/use_case
parent2181d0ac35f30202985a877950c88325ff665f6b (diff)
downloadml-embedded-evaluation-kit-f9c19eaa9ab11e4409679fc6d2862c89410493a7.tar.gz
MLECO-1860: Support for Arm GNU Embedded Toolchain
This patch enables compilation of ML use cases bare-metal applications using Arm GNU Embedded Toolchain. The GNU toolchain can be used instead of the Arm Compiler that was already supported. The GNU toolchain is also set as the default toolchain when building applications for the MPS3 target. Note: The version of GNU toolchain must be 10.2.1 or higher. Change-Id: I5fff242f0f52d2db6c75d292f9fa990df1aec978 Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
Diffstat (limited to 'source/use_case')
-rw-r--r--source/use_case/ad/src/MelSpectrogram.cc21
-rw-r--r--source/use_case/ad/src/UseCaseHandler.cc4
-rw-r--r--source/use_case/asr/src/AsrClassifier.cc2
-rw-r--r--source/use_case/asr/src/MainLoop.cc2
-rw-r--r--source/use_case/asr/src/UseCaseHandler.cc9
-rw-r--r--source/use_case/asr/src/Wav2LetterPostprocess.cc4
-rw-r--r--source/use_case/img_class/src/UseCaseHandler.cc15
-rw-r--r--source/use_case/kws/src/UseCaseHandler.cc10
-rw-r--r--source/use_case/kws_asr/src/AsrClassifier.cc2
-rw-r--r--source/use_case/kws_asr/src/MainLoop.cc2
-rw-r--r--source/use_case/kws_asr/src/UseCaseHandler.cc18
-rw-r--r--source/use_case/kws_asr/src/Wav2LetterPostprocess.cc4
-rw-r--r--source/use_case/kws_asr/usecase.cmake14
13 files changed, 51 insertions, 56 deletions
diff --git a/source/use_case/ad/src/MelSpectrogram.cc b/source/use_case/ad/src/MelSpectrogram.cc
index 372ebd8..f1752e1 100644
--- a/source/use_case/ad/src/MelSpectrogram.cc
+++ b/source/use_case/ad/src/MelSpectrogram.cc
@@ -19,6 +19,7 @@
#include "PlatformMath.hpp"
#include <cfloat>
+#include <inttypes.h>
namespace arm {
namespace app {
@@ -46,16 +47,16 @@ namespace audio {
{
char strC[1024];
snprintf(strC, sizeof(strC) - 1, "\n \
- \n\t Sampling frequency: %f\
- \n\t Number of filter banks: %u\
- \n\t Mel frequency limit (low): %f\
- \n\t Mel frequency limit (high): %f\
- \n\t Frame length: %u\
- \n\t Padded frame length: %u\
- \n\t Using HTK for Mel scale: %s\n",
- this->m_samplingFreq, this->m_numFbankBins, this->m_melLoFreq,
- this->m_melHiFreq, this->m_frameLen,
- this->m_frameLenPadded, this->m_useHtkMethod ? "yes" : "no");
+ \n\t Sampling frequency: %f\
+ \n\t Number of filter banks: %" PRIu32 "\
+ \n\t Mel frequency limit (low): %f\
+ \n\t Mel frequency limit (high): %f\
+ \n\t Frame length: %" PRIu32 "\
+ \n\t Padded frame length: %" PRIu32 "\
+ \n\t Using HTK for Mel scale: %s\n",
+ this->m_samplingFreq, this->m_numFbankBins, this->m_melLoFreq,
+ this->m_melHiFreq, this->m_frameLen,
+ this->m_frameLenPadded, this->m_useHtkMethod ? "yes" : "no");
return std::string{strC};
}
diff --git a/source/use_case/ad/src/UseCaseHandler.cc b/source/use_case/ad/src/UseCaseHandler.cc
index e99821f..233b0f4 100644
--- a/source/use_case/ad/src/UseCaseHandler.cc
+++ b/source/use_case/ad/src/UseCaseHandler.cc
@@ -167,7 +167,7 @@ namespace app {
platform.data_psn->present_data_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
- info("Running inference on audio clip %u => %s\n", currentIndex, get_filename(currentIndex));
+ info("Running inference on audio clip %" PRIu32 " => %s\n", currentIndex, get_filename(currentIndex));
/* Start sliding through audio clip. */
while (audioDataSlider.HasNext()) {
@@ -246,7 +246,7 @@ namespace app {
static bool SetAppCtxClipIdx(ApplicationContext& ctx, uint32_t idx)
{
if (idx >= NUMBER_OF_FILES) {
- printf_err("Invalid idx %u (expected less than %u)\n",
+ printf_err("Invalid idx %" PRIu32 " (expected less than %u)\n",
idx, NUMBER_OF_FILES);
return false;
}
diff --git a/source/use_case/asr/src/AsrClassifier.cc b/source/use_case/asr/src/AsrClassifier.cc
index df26a7f..c18bd88 100644
--- a/source/use_case/asr/src/AsrClassifier.cc
+++ b/source/use_case/asr/src/AsrClassifier.cc
@@ -91,7 +91,7 @@ bool arm::app::AsrClassifier::GetClassificationResults(
printf_err("Output tensor expected to be %dD\n", minTensorDims);
return false;
} else if (static_cast<uint32_t>(outputTensor->dims->data[outColsIdx]) < topNCount) {
- printf_err("Output vectors are smaller than %u\n", topNCount);
+ printf_err("Output vectors are smaller than %" PRIu32 "\n", topNCount);
return false;
} else if (static_cast<uint32_t>(outputTensor->dims->data[outColsIdx]) != labels.size()) {
printf("Output size doesn't match the labels' size\n");
diff --git a/source/use_case/asr/src/MainLoop.cc b/source/use_case/asr/src/MainLoop.cc
index c5a26a4..9950541 100644
--- a/source/use_case/asr/src/MainLoop.cc
+++ b/source/use_case/asr/src/MainLoop.cc
@@ -208,7 +208,7 @@ static uint32_t GetOutputContextLen(const arm::app::Model& model, const uint32_t
/* Check to make sure that the input tensor supports the above
* context and inner lengths. */
if (inputRows <= 2 * inputCtxLen || inputRows <= inputInnerLen) {
- printf_err("Input rows not compatible with ctx of %u\n",
+ printf_err("Input rows not compatible with ctx of %" PRIu32 "\n",
inputCtxLen);
return 0;
}
diff --git a/source/use_case/asr/src/UseCaseHandler.cc b/source/use_case/asr/src/UseCaseHandler.cc
index 7199785..43b17dc 100644
--- a/source/use_case/asr/src/UseCaseHandler.cc
+++ b/source/use_case/asr/src/UseCaseHandler.cc
@@ -131,7 +131,8 @@ namespace app {
/* Audio clip must have enough samples to produce 1 MFCC feature. */
if (audioArrSize < mfccParamsWinLen) {
- printf_err("Not enough audio samples, minimum needed is %u\n", mfccParamsWinLen);
+ printf_err("Not enough audio samples, minimum needed is %" PRIu32 "\n",
+ mfccParamsWinLen);
return false;
}
@@ -151,7 +152,7 @@ namespace app {
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
- info("Running inference on audio clip %u => %s\n", currentIndex,
+ info("Running inference on audio clip %" PRIu32 " => %s\n", currentIndex,
get_filename(currentIndex));
size_t inferenceWindowLen = audioParamsWinLen;
@@ -237,7 +238,7 @@ namespace app {
static bool SetAppCtxClipIdx(ApplicationContext& ctx, uint32_t idx)
{
if (idx >= NUMBER_OF_FILES) {
- printf_err("Invalid idx %u (expected less than %u)\n",
+ printf_err("Invalid idx %" PRIu32 " (expected less than %u)\n",
idx, NUMBER_OF_FILES);
return false;
}
@@ -269,7 +270,7 @@ namespace app {
for (const auto & result : results) {
std::string infResultStr = audio::asr::DecodeOutput(result.m_resultVec);
- info("For timestamp: %f (inference #: %u); label: %s\n",
+ info("For timestamp: %f (inference #: %" PRIu32 "); label: %s\n",
result.m_timeStamp, result.m_inferenceNumber,
infResultStr.c_str());
}
diff --git a/source/use_case/asr/src/Wav2LetterPostprocess.cc b/source/use_case/asr/src/Wav2LetterPostprocess.cc
index 9157a6f..b1bcdc8 100644
--- a/source/use_case/asr/src/Wav2LetterPostprocess.cc
+++ b/source/use_case/asr/src/Wav2LetterPostprocess.cc
@@ -69,7 +69,7 @@ namespace asr {
tensor->dims->data[arm::app::Wav2LetterModel::ms_outputRowsIdx],
lastIteration);
default:
- printf_err("Unsupported axis index: %u\n", axisIdx);
+ printf_err("Unsupported axis index: %" PRIu32 "\n", axisIdx);
}
return false;
@@ -83,7 +83,7 @@ namespace asr {
}
if (static_cast<int>(axisIdx) >= tensor->dims->size) {
- printf_err("Invalid axis index: %u; Max: %d\n",
+ printf_err("Invalid axis index: %" PRIu32 "; Max: %d\n",
axisIdx, tensor->dims->size);
return false;
}
diff --git a/source/use_case/img_class/src/UseCaseHandler.cc b/source/use_case/img_class/src/UseCaseHandler.cc
index 22e6ba0..fa77512 100644
--- a/source/use_case/img_class/src/UseCaseHandler.cc
+++ b/source/use_case/img_class/src/UseCaseHandler.cc
@@ -22,6 +22,8 @@
#include "UseCaseCommonUtils.hpp"
#include "hal.h"
+#include <inttypes.h>
+
using ImgClassClassifier = arm::app::Classifier;
namespace arm {
@@ -142,7 +144,7 @@ namespace app {
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
/* Run inference over this image. */
- info("Running inference on image %u => %s\n", ctx.Get<uint32_t>("imgIndex"),
+ info("Running inference on image %" PRIu32 " => %s\n", ctx.Get<uint32_t>("imgIndex"),
get_filename(ctx.Get<uint32_t>("imgIndex")));
if (!RunInference(model, profiler)) {
@@ -185,13 +187,13 @@ namespace app {
inputTensor->bytes : IMAGE_DATA_SIZE;
const uint8_t* imgSrc = get_img_array(imIdx);
if (nullptr == imgSrc) {
- printf_err("Failed to get image index %u (max: %u)\n", imIdx,
+ printf_err("Failed to get image index %" PRIu32 " (max: %u)\n", imIdx,
NUMBER_OF_FILES - 1);
return false;
}
memcpy(inputTensor->data.data, imgSrc, copySz);
- debug("Image %u loaded\n", imIdx);
+ debug("Image %" PRIu32 " loaded\n", imIdx);
return true;
}
@@ -210,7 +212,7 @@ namespace app {
static bool SetAppCtxImageIdx(ApplicationContext& ctx, uint32_t idx)
{
if (idx >= NUMBER_OF_FILES) {
- printf_err("Invalid idx %u (expected less than %u)\n",
+ printf_err("Invalid idx %" PRIu32 " (expected less than %u)\n",
idx, NUMBER_OF_FILES);
return false;
}
@@ -254,8 +256,9 @@ namespace app {
dataPsnTxtStartX2, rowIdx2, 0);
rowIdx2 += dataPsnTxtYIncr;
- info("%u) %u (%f) -> %s\n", i, results[i].m_labelIdx,
- results[i].m_normalisedVal, results[i].m_label.c_str());
+ info("%" PRIu32 ") %" PRIu32 " (%f) -> %s\n", i,
+ results[i].m_labelIdx, results[i].m_normalisedVal,
+ results[i].m_label.c_str());
}
return true;
diff --git a/source/use_case/kws/src/UseCaseHandler.cc b/source/use_case/kws/src/UseCaseHandler.cc
index d61985d..eaf53c1 100644
--- a/source/use_case/kws/src/UseCaseHandler.cc
+++ b/source/use_case/kws/src/UseCaseHandler.cc
@@ -187,7 +187,7 @@ namespace app {
platform.data_psn->present_data_text(
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, 0);
- info("Running inference on audio clip %u => %s\n", currentIndex,
+ info("Running inference on audio clip %" PRIu32 " => %s\n", currentIndex,
get_filename(currentIndex));
/* Start sliding through audio clip. */
@@ -270,7 +270,7 @@ namespace app {
static bool SetAppCtxClipIdx(ApplicationContext& ctx, uint32_t idx)
{
if (idx >= NUMBER_OF_FILES) {
- printf_err("Invalid idx %u (expected less than %u)\n",
+ printf_err("Invalid idx %" PRIu32 " (expected less than %u)\n",
idx, NUMBER_OF_FILES);
return false;
}
@@ -313,13 +313,15 @@ namespace app {
rowIdx1 += dataPsnTxtYIncr;
if (results[i].m_resultVec.empty()) {
- info("For timestamp: %f (inference #: %u); label: %s; threshold: %f\n",
+ info("For timestamp: %f (inference #: %" PRIu32
+ "); label: %s; threshold: %f\n",
results[i].m_timeStamp, results[i].m_inferenceNumber,
topKeyword.c_str(),
results[i].m_threshold);
} else {
for (uint32_t j = 0; j < results[i].m_resultVec.size(); ++j) {
- info("For timestamp: %f (inference #: %u); label: %s, score: %f; threshold: %f\n",
+ info("For timestamp: %f (inference #: %" PRIu32
+ "); label: %s, score: %f; threshold: %f\n",
results[i].m_timeStamp,
results[i].m_inferenceNumber,
results[i].m_resultVec[j].m_label.c_str(),
diff --git a/source/use_case/kws_asr/src/AsrClassifier.cc b/source/use_case/kws_asr/src/AsrClassifier.cc
index f1fa6f1..57d5058 100644
--- a/source/use_case/kws_asr/src/AsrClassifier.cc
+++ b/source/use_case/kws_asr/src/AsrClassifier.cc
@@ -91,7 +91,7 @@ bool arm::app::AsrClassifier::GetClassificationResults(
printf_err("Output tensor expected to be 3D (1, m, n)\n");
return false;
} else if (static_cast<uint32_t>(outputTensor->dims->data[outColsIdx]) < topNCount) {
- printf_err("Output vectors are smaller than %u\n", topNCount);
+ printf_err("Output vectors are smaller than %" PRIu32 "\n", topNCount);
return false;
} else if (static_cast<uint32_t>(outputTensor->dims->data[outColsIdx]) != labels.size()) {
printf("Output size doesn't match the labels' size\n");
diff --git a/source/use_case/kws_asr/src/MainLoop.cc b/source/use_case/kws_asr/src/MainLoop.cc
index 95e5a8f..631b7c1 100644
--- a/source/use_case/kws_asr/src/MainLoop.cc
+++ b/source/use_case/kws_asr/src/MainLoop.cc
@@ -212,7 +212,7 @@ static uint32_t GetOutputContextLen(const arm::app::Model& model, const uint32_t
/* Check to make sure that the input tensor supports the above context and inner lengths. */
if (inputRows <= 2 * inputCtxLen || inputRows <= inputInnerLen) {
- printf_err("Input rows not compatible with ctx of %u\n",
+ printf_err("Input rows not compatible with ctx of %" PRIu32 "\n",
inputCtxLen);
return 0;
}
diff --git a/source/use_case/kws_asr/src/UseCaseHandler.cc b/source/use_case/kws_asr/src/UseCaseHandler.cc
index 7025d6d..0560e88 100644
--- a/source/use_case/kws_asr/src/UseCaseHandler.cc
+++ b/source/use_case/kws_asr/src/UseCaseHandler.cc
@@ -159,7 +159,7 @@ namespace app {
* this means an overlap of 0.5 seconds. */
auto kwsAudioDataStride = kwsAudioDataWindowSize / 2;
- info("KWS audio data window size %u\n", kwsAudioDataWindowSize);
+ info("KWS audio data window size %" PRIu32 "\n", kwsAudioDataWindowSize);
/* Stride must be multiple of mfcc features window stride to re-use features. */
if (0 != kwsAudioDataStride % kwsMfccWindowStride) {
@@ -208,7 +208,7 @@ namespace app {
str_inf.c_str(), str_inf.size(),
dataPsnTxtInfStartX, dataPsnTxtInfStartY, false);
- info("Running KWS inference on audio clip %u => %s\n",
+ info("Running KWS inference on audio clip %" PRIu32 " => %s\n",
currentIndex, get_filename(currentIndex));
/* Start sliding through audio clip. */
@@ -329,7 +329,8 @@ namespace app {
/* Make sure the input tensor supports the above context and inner lengths. */
if (asrInputRows <= 2 * asrInputCtxLen || asrInputRows <= asrInputInnerLen) {
- printf_err("ASR input rows not compatible with ctx length %u\n", asrInputCtxLen);
+ printf_err("ASR input rows not compatible with ctx length %" PRIu32 "\n",
+ asrInputCtxLen);
return false;
}
@@ -354,7 +355,8 @@ namespace app {
/* Audio clip must have enough samples to produce 1 MFCC feature. */
std::vector<int16_t> audioBuffer = std::vector<int16_t>(audioArr, audioArr + audioArrSize);
if (audioArrSize < asrMfccParamsWinLen) {
- printf_err("Not enough audio samples, minimum needed is %u\n", asrMfccParamsWinLen);
+ printf_err("Not enough audio samples, minimum needed is %" PRIu32 "\n",
+ asrMfccParamsWinLen);
return false;
}
@@ -485,7 +487,7 @@ namespace app {
static bool SetAppCtxClipIdx(ApplicationContext& ctx, uint32_t idx)
{
if (idx >= NUMBER_OF_FILES) {
- printf_err("Invalid idx %u (expected less than %u)\n",
+ printf_err("Invalid idx %" PRIu32 " (expected less than %u)\n",
idx, NUMBER_OF_FILES);
return false;
}
@@ -525,11 +527,11 @@ namespace app {
dataPsnTxtStartX1, rowIdx1, 0);
rowIdx1 += dataPsnTxtYIncr;
- info("For timestamp: %f (inference #: %u); threshold: %f\n",
+ info("For timestamp: %f (inference #: %" PRIu32 "); threshold: %f\n",
results[i].m_timeStamp, results[i].m_inferenceNumber,
results[i].m_threshold);
for (uint32_t j = 0; j < results[i].m_resultVec.size(); ++j) {
- info("\t\tlabel @ %u: %s, score: %f\n", j,
+ info("\t\tlabel @ %" PRIu32 ": %s, score: %f\n", j,
results[i].m_resultVec[j].m_label.c_str(),
results[i].m_resultVec[j].m_normalisedVal);
}
@@ -558,7 +560,7 @@ namespace app {
/* Get the final result string using the decoder. */
std::string infResultStr = audio::asr::DecodeOutput(result.m_resultVec);
- info("Result for inf %u: %s\n", result.m_inferenceNumber,
+ info("Result for inf %" PRIu32 ": %s\n", result.m_inferenceNumber,
infResultStr.c_str());
}
diff --git a/source/use_case/kws_asr/src/Wav2LetterPostprocess.cc b/source/use_case/kws_asr/src/Wav2LetterPostprocess.cc
index ee3aba0..e3c0c20 100644
--- a/source/use_case/kws_asr/src/Wav2LetterPostprocess.cc
+++ b/source/use_case/kws_asr/src/Wav2LetterPostprocess.cc
@@ -63,7 +63,7 @@ namespace asr {
tensor->dims->data[arm::app::Wav2LetterModel::ms_outputColsIdx],
lastIteration);
default:
- printf_err("Unsupported axis index: %u\n", axisIdx);
+ printf_err("Unsupported axis index: %" PRIu32 "\n", axisIdx);
}
return false;
@@ -77,7 +77,7 @@ namespace asr {
}
if (static_cast<int>(axisIdx) >= tensor->dims->size) {
- printf_err("Invalid axis index: %u; Max: %d\n",
+ printf_err("Invalid axis index: %" PRIu32 "; Max: %d\n",
axisIdx, tensor->dims->size);
return false;
}
diff --git a/source/use_case/kws_asr/usecase.cmake b/source/use_case/kws_asr/usecase.cmake
index d8ac897..3eb61e5 100644
--- a/source/use_case/kws_asr/usecase.cmake
+++ b/source/use_case/kws_asr/usecase.cmake
@@ -15,20 +15,6 @@
# limitations under the License.
#----------------------------------------------------------------------------
-# If the path to a directory or source file has been defined,
-# get the type here (FILEPATH or PATH):
-#if (DEFINED ${use_case}_FILE_PATH)
-# get_path_type(${${use_case}_FILE_PATH} PATH_TYPE)
-#
-# # Set the default type if path is not a dir or file path (or undefined)
-# if (NOT ${PATH_TYPE} STREQUAL PATH AND NOT ${PATH_TYPE} STREQUAL FILEPATH)
-# message(FATAL_ERROR "Invalid ${use_case}_FILE_PATH. It should be a dir or file path.")
-# endif()
-#else()
-# # Default is a directory path
-# set(PATH_TYPE PATH)
-#endif()
-
USER_OPTION(${use_case}_FILE_PATH "Directory with WAV files, or path to a single WAV file, to use in the evaluation application."
${CMAKE_CURRENT_SOURCE_DIR}/resources/${use_case}/samples/
PATH_OR_FILE)