summaryrefslogtreecommitdiff
path: root/source/application
diff options
context:
space:
mode:
Diffstat (limited to 'source/application')
-rw-r--r--source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/include/stubs_fvp.h8
-rw-r--r--source/application/hal/platforms/native/data_presentation/log/include/log.h1
-rw-r--r--source/application/main/Mfcc.cc126
-rw-r--r--source/application/main/Profiler.cc44
-rw-r--r--source/application/main/include/AppContext.hpp18
-rw-r--r--source/application/main/include/DataStructures.hpp36
-rw-r--r--source/application/main/include/Mfcc.hpp34
-rw-r--r--source/application/main/include/Profiler.hpp12
-rw-r--r--source/application/main/include/UseCaseCommonUtils.hpp3
-rw-r--r--source/application/tensorflow-lite-micro/Model.cc102
-rw-r--r--source/application/tensorflow-lite-micro/include/Model.hpp20
11 files changed, 198 insertions, 206 deletions
diff --git a/source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/include/stubs_fvp.h b/source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/include/stubs_fvp.h
index a21f2d2..aec0be1 100644
--- a/source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/include/stubs_fvp.h
+++ b/source/application/hal/platforms/bare-metal/bsp/bsp-packs/simple_platform/include/stubs_fvp.h
@@ -35,7 +35,6 @@ uint32_t GetCoreClock(void);
/************************ GLCD related functions ****************************/
/**
* @brief Initialize the Himax LCD with HX8347-D LCD Controller
- * @return none
*/
void GLCD_Initialize(void);
@@ -48,7 +47,6 @@ void GLCD_Initialize(void);
* @param[in] w width of bitmap.
* @param[in] h height of bitmap.
* @param[in] bitmap address at which the bitmap data resides.
- * @return none
*/
void GLCD_Bitmap(unsigned int x, unsigned int y,
unsigned int w, unsigned int h,
@@ -65,7 +63,6 @@ void GLCD_Bitmap(unsigned int x, unsigned int y,
* @param[in] pos_y start y position for the LCD.
* @param[in] downsample_factor factor by which the image
* is downsampled by.
- * @return none
*/
void GLCD_Image(void *data, const uint32_t width,
const uint32_t height, const uint32_t channels,
@@ -75,14 +72,12 @@ void GLCD_Image(void *data, const uint32_t width,
/**
* @brief Clear display
* @param[in] color display clearing color
- * @return none
*/
void GLCD_Clear(unsigned short color);
/**
* @brief Set foreground color
* @param[in] color foreground color
- * @return none
*/
void GLCD_SetTextColor(unsigned short color);
@@ -92,7 +87,6 @@ void GLCD_SetTextColor(unsigned short color);
* @param[in] col column number
* @param[in] fi font index (0 = 9x15)
* @param[in] c ASCII character
- * @return none
*/
void GLCD_DisplayChar(unsigned int ln, unsigned int col,
unsigned char fi, unsigned char c);
@@ -103,7 +97,6 @@ void GLCD_DisplayChar(unsigned int ln, unsigned int col,
* @param[in] col column number
* @param[in] fi font index (0 = 9x15)
* @param[in] s pointer to string
- * @return none
*/
void GLCD_DisplayString(unsigned int ln, unsigned int col,
unsigned char fi, char *s);
@@ -115,7 +108,6 @@ void GLCD_DisplayString(unsigned int ln, unsigned int col,
* @param[in] w: window width in pixels
* @param[in] h: window height in pixels
* @param[in] color box color
- * @return none
*/
void GLCD_Box(unsigned int x, unsigned int y,
unsigned int w, unsigned int h,
diff --git a/source/application/hal/platforms/native/data_presentation/log/include/log.h b/source/application/hal/platforms/native/data_presentation/log/include/log.h
index 10cf303..9b9928f 100644
--- a/source/application/hal/platforms/native/data_presentation/log/include/log.h
+++ b/source/application/hal/platforms/native/data_presentation/log/include/log.h
@@ -50,6 +50,7 @@ int log_display_image(uint8_t* data, const uint32_t width,
* @param[in] str_sz Length of the string.
* @param[in] pos_x Screen position x co-ordinate.
* @param[in] pos_y Screen position y co-ordinate.
+ * @param[in] allow_multiple_lines Specifies if multiple lines are allowed.
* @return 0 if successful, non-zero otherwise.
**/
int log_display_text(const char* str, const size_t str_sz,
diff --git a/source/application/main/Mfcc.cc b/source/application/main/Mfcc.cc
index c8ad138..c998ef2 100644
--- a/source/application/main/Mfcc.cc
+++ b/source/application/main/Mfcc.cc
@@ -64,27 +64,27 @@ namespace audio {
}
MFCC::MFCC(const MfccParams& params):
- _m_params(params),
- _m_filterBankInitialised(false)
+ m_params(params),
+ m_filterBankInitialised(false)
{
- this->_m_buffer = std::vector<float>(
- this->_m_params.m_frameLenPadded, 0.0);
- this->_m_frame = std::vector<float>(
- this->_m_params.m_frameLenPadded, 0.0);
- this->_m_melEnergies = std::vector<float>(
- this->_m_params.m_numFbankBins, 0.0);
+ this->m_buffer = std::vector<float>(
+ this->m_params.m_frameLenPadded, 0.0);
+ this->m_frame = std::vector<float>(
+ this->m_params.m_frameLenPadded, 0.0);
+ this->m_melEnergies = std::vector<float>(
+ this->m_params.m_numFbankBins, 0.0);
- this->_m_windowFunc = std::vector<float>(this->_m_params.m_frameLen);
- const auto multiplier = static_cast<float>(2 * M_PI / this->_m_params.m_frameLen);
+ this->m_windowFunc = std::vector<float>(this->m_params.m_frameLen);
+ const auto multiplier = static_cast<float>(2 * M_PI / this->m_params.m_frameLen);
/* Create window function. */
- for (size_t i = 0; i < this->_m_params.m_frameLen; i++) {
- this->_m_windowFunc[i] = (0.5 - (0.5 *
+ for (size_t i = 0; i < this->m_params.m_frameLen; i++) {
+ this->m_windowFunc[i] = (0.5 - (0.5 *
math::MathUtils::CosineF32(static_cast<float>(i) * multiplier)));
}
- math::MathUtils::FftInitF32(this->_m_params.m_frameLenPadded, this->_m_fftInstance);
- debug("Instantiated MFCC object: %s\n", this->_m_params.Str().c_str());
+ math::MathUtils::FftInitF32(this->m_params.m_frameLenPadded, this->m_fftInstance);
+ debug("Instantiated MFCC object: %s\n", this->m_params.Str().c_str());
}
void MFCC::Init()
@@ -166,20 +166,20 @@ namespace audio {
void MFCC::ConvertToPowerSpectrum()
{
- const uint32_t halfDim = this->_m_buffer.size() / 2;
+ const uint32_t halfDim = this->m_buffer.size() / 2;
/* Handle this special case. */
- float firstEnergy = this->_m_buffer[0] * this->_m_buffer[0];
- float lastEnergy = this->_m_buffer[1] * this->_m_buffer[1];
+ float firstEnergy = this->m_buffer[0] * this->m_buffer[0];
+ float lastEnergy = this->m_buffer[1] * this->m_buffer[1];
math::MathUtils::ComplexMagnitudeSquaredF32(
- this->_m_buffer.data(),
- this->_m_buffer.size(),
- this->_m_buffer.data(),
- this->_m_buffer.size()/2);
+ this->m_buffer.data(),
+ this->m_buffer.size(),
+ this->m_buffer.data(),
+ this->m_buffer.size()/2);
- this->_m_buffer[0] = firstEnergy;
- this->_m_buffer[halfDim] = lastEnergy;
+ this->m_buffer[0] = firstEnergy;
+ this->m_buffer[halfDim] = lastEnergy;
}
std::vector<float> MFCC::CreateDCTMatrix(
@@ -219,17 +219,17 @@ namespace audio {
void MFCC::InitMelFilterBank()
{
if (!this->IsMelFilterBankInited()) {
- this->_m_melFilterBank = this->CreateMelFilterBank();
- this->_m_dctMatrix = this->CreateDCTMatrix(
- this->_m_params.m_numFbankBins,
- this->_m_params.m_numMfccFeatures);
- this->_m_filterBankInitialised = true;
+ this->m_melFilterBank = this->CreateMelFilterBank();
+ this->m_dctMatrix = this->CreateDCTMatrix(
+ this->m_params.m_numFbankBins,
+ this->m_params.m_numMfccFeatures);
+ this->m_filterBankInitialised = true;
}
}
bool MFCC::IsMelFilterBankInited() const
{
- return this->_m_filterBankInitialised;
+ return this->m_filterBankInitialised;
}
void MFCC::MfccComputePreFeature(const std::vector<int16_t>& audioData)
@@ -238,78 +238,78 @@ namespace audio {
/* TensorFlow way of normalizing .wav data to (-1, 1). */
constexpr float normaliser = 1.0/(1u<<15u);
- for (size_t i = 0; i < this->_m_params.m_frameLen; i++) {
- this->_m_frame[i] = static_cast<float>(audioData[i]) * normaliser;
+ for (size_t i = 0; i < this->m_params.m_frameLen; i++) {
+ this->m_frame[i] = static_cast<float>(audioData[i]) * normaliser;
}
/* Apply window function to input frame. */
- for(size_t i = 0; i < this->_m_params.m_frameLen; i++) {
- this->_m_frame[i] *= this->_m_windowFunc[i];
+ for(size_t i = 0; i < this->m_params.m_frameLen; i++) {
+ this->m_frame[i] *= this->m_windowFunc[i];
}
/* Set remaining frame values to 0. */
- std::fill(this->_m_frame.begin() + this->_m_params.m_frameLen,this->_m_frame.end(), 0);
+ std::fill(this->m_frame.begin() + this->m_params.m_frameLen,this->m_frame.end(), 0);
/* Compute FFT. */
- math::MathUtils::FftF32(this->_m_frame, this->_m_buffer, this->_m_fftInstance);
+ math::MathUtils::FftF32(this->m_frame, this->m_buffer, this->m_fftInstance);
/* Convert to power spectrum. */
this->ConvertToPowerSpectrum();
/* Apply mel filterbanks. */
- if (!this->ApplyMelFilterBank(this->_m_buffer,
- this->_m_melFilterBank,
- this->_m_filterBankFilterFirst,
- this->_m_filterBankFilterLast,
- this->_m_melEnergies)) {
+ if (!this->ApplyMelFilterBank(this->m_buffer,
+ this->m_melFilterBank,
+ this->m_filterBankFilterFirst,
+ this->m_filterBankFilterLast,
+ this->m_melEnergies)) {
printf_err("Failed to apply MEL filter banks\n");
}
/* Convert to logarithmic scale. */
- this->ConvertToLogarithmicScale(this->_m_melEnergies);
+ this->ConvertToLogarithmicScale(this->m_melEnergies);
}
std::vector<float> MFCC::MfccCompute(const std::vector<int16_t>& audioData)
{
this->MfccComputePreFeature(audioData);
- std::vector<float> mfccOut(this->_m_params.m_numMfccFeatures);
+ std::vector<float> mfccOut(this->m_params.m_numMfccFeatures);
- float * ptrMel = this->_m_melEnergies.data();
- float * ptrDct = this->_m_dctMatrix.data();
+ float * ptrMel = this->m_melEnergies.data();
+ float * ptrDct = this->m_dctMatrix.data();
float * ptrMfcc = mfccOut.data();
/* Take DCT. Uses matrix mul. */
for (size_t i = 0, j = 0; i < mfccOut.size();
- ++i, j += this->_m_params.m_numFbankBins) {
+ ++i, j += this->m_params.m_numFbankBins) {
*ptrMfcc++ = math::MathUtils::DotProductF32(
ptrDct + j,
ptrMel,
- this->_m_params.m_numFbankBins);
+ this->m_params.m_numFbankBins);
}
return mfccOut;
}
std::vector<std::vector<float>> MFCC::CreateMelFilterBank()
{
- size_t numFftBins = this->_m_params.m_frameLenPadded / 2;
- float fftBinWidth = static_cast<float>(this->_m_params.m_samplingFreq) / this->_m_params.m_frameLenPadded;
+ size_t numFftBins = this->m_params.m_frameLenPadded / 2;
+ float fftBinWidth = static_cast<float>(this->m_params.m_samplingFreq) / this->m_params.m_frameLenPadded;
- float melLowFreq = MFCC::MelScale(this->_m_params.m_melLoFreq,
- this->_m_params.m_useHtkMethod);
- float melHighFreq = MFCC::MelScale(this->_m_params.m_melHiFreq,
- this->_m_params.m_useHtkMethod);
- float melFreqDelta = (melHighFreq - melLowFreq) / (this->_m_params.m_numFbankBins + 1);
+ float melLowFreq = MFCC::MelScale(this->m_params.m_melLoFreq,
+ this->m_params.m_useHtkMethod);
+ float melHighFreq = MFCC::MelScale(this->m_params.m_melHiFreq,
+ this->m_params.m_useHtkMethod);
+ float melFreqDelta = (melHighFreq - melLowFreq) / (this->m_params.m_numFbankBins + 1);
std::vector<float> thisBin = std::vector<float>(numFftBins);
std::vector<std::vector<float>> melFilterBank(
- this->_m_params.m_numFbankBins);
- this->_m_filterBankFilterFirst =
- std::vector<uint32_t>(this->_m_params.m_numFbankBins);
- this->_m_filterBankFilterLast =
- std::vector<uint32_t>(this->_m_params.m_numFbankBins);
+ this->m_params.m_numFbankBins);
+ this->m_filterBankFilterFirst =
+ std::vector<uint32_t>(this->m_params.m_numFbankBins);
+ this->m_filterBankFilterLast =
+ std::vector<uint32_t>(this->m_params.m_numFbankBins);
- for (size_t bin = 0; bin < this->_m_params.m_numFbankBins; bin++) {
+ for (size_t bin = 0; bin < this->m_params.m_numFbankBins; bin++) {
float leftMel = melLowFreq + bin * melFreqDelta;
float centerMel = melLowFreq + (bin + 1) * melFreqDelta;
float rightMel = melLowFreq + (bin + 2) * melFreqDelta;
@@ -317,11 +317,11 @@ namespace audio {
uint32_t firstIndex = 0;
uint32_t lastIndex = 0;
bool firstIndexFound = false;
- const float normaliser = this->GetMelFilterBankNormaliser(leftMel, rightMel, this->_m_params.m_useHtkMethod);
+ const float normaliser = this->GetMelFilterBankNormaliser(leftMel, rightMel, this->m_params.m_useHtkMethod);
for (size_t i = 0; i < numFftBins; i++) {
float freq = (fftBinWidth * i); /* Center freq of this fft bin. */
- float mel = MFCC::MelScale(freq, this->_m_params.m_useHtkMethod);
+ float mel = MFCC::MelScale(freq, this->m_params.m_useHtkMethod);
thisBin[i] = 0.0;
if (mel > leftMel && mel < rightMel) {
@@ -341,8 +341,8 @@ namespace audio {
}
}
- this->_m_filterBankFilterFirst[bin] = firstIndex;
- this->_m_filterBankFilterLast[bin] = lastIndex;
+ this->m_filterBankFilterFirst[bin] = firstIndex;
+ this->m_filterBankFilterLast[bin] = lastIndex;
/* Copy the part we care about. */
for (uint32_t i = firstIndex; i <= lastIndex; i++) {
diff --git a/source/application/main/Profiler.cc b/source/application/main/Profiler.cc
index 5924414..d8a6fa3 100644
--- a/source/application/main/Profiler.cc
+++ b/source/application/main/Profiler.cc
@@ -22,14 +22,14 @@
namespace arm {
namespace app {
Profiler::Profiler(hal_platform* platform, const char* name = "Unknown")
- : _m_name(name)
+ : m_name(name)
{
if (platform && platform->inited) {
- this->_m_pPlatform = platform;
+ this->m_pPlatform = platform;
this->Reset();
} else {
printf_err("Profiler %s initialised with invalid platform\n",
- this->_m_name.c_str());
+ this->m_name.c_str());
}
}
@@ -38,27 +38,27 @@ namespace app {
if (name) {
this->SetName(name);
}
- if (this->_m_pPlatform && !this->_m_started) {
- this->_m_pPlatform->timer->reset();
- this->_m_tstampSt = this->_m_pPlatform->timer->start_profiling();
- this->_m_started = true;
+ if (this->m_pPlatform && !this->m_started) {
+ this->m_pPlatform->timer->reset();
+ this->m_tstampSt = this->m_pPlatform->timer->start_profiling();
+ this->m_started = true;
return true;
}
- printf_err("Failed to start profiler %s\n", this->_m_name.c_str());
+ printf_err("Failed to start profiler %s\n", this->m_name.c_str());
return false;
}
bool Profiler::StopProfiling()
{
- if (this->_m_pPlatform && this->_m_started) {
- this->_m_tstampEnd = this->_m_pPlatform->timer->stop_profiling();
- this->_m_started = false;
+ if (this->m_pPlatform && this->m_started) {
+ this->m_tstampEnd = this->m_pPlatform->timer->stop_profiling();
+ this->m_started = false;
- this->AddProfilingUnit(this->_m_tstampSt, this->_m_tstampEnd, this->_m_name);
+ this->AddProfilingUnit(this->m_tstampSt, this->m_tstampEnd, this->m_name);
return true;
}
- printf_err("Failed to stop profiler %s\n", this->_m_name.c_str());
+ printf_err("Failed to stop profiler %s\n", this->m_name.c_str());
return false;
}
@@ -68,16 +68,16 @@ namespace app {
this->Reset();
return true;
}
- printf_err("Failed to stop profiler %s\n", this->_m_name.c_str());
+ printf_err("Failed to stop profiler %s\n", this->m_name.c_str());
return false;
}
void Profiler::Reset()
{
- this->_m_started = false;
- this->_m_series.clear();
- memset(&this->_m_tstampSt, 0, sizeof(this->_m_tstampSt));
- memset(&this->_m_tstampEnd, 0, sizeof(this->_m_tstampEnd));
+ this->m_started = false;
+ this->m_series.clear();
+ memset(&this->m_tstampSt, 0, sizeof(this->m_tstampSt));
+ memset(&this->m_tstampEnd, 0, sizeof(this->m_tstampEnd));
}
void calcProfilingStat(uint64_t currentValue,
@@ -92,7 +92,7 @@ namespace app {
void Profiler::GetAllResultsAndReset(std::vector<ProfileResult>& results)
{
- for (const auto& item: this->_m_series) {
+ for (const auto& item: this->m_series) {
auto name = item.first;
ProfilingSeries series = item.second;
ProfileResult result{};
@@ -236,13 +236,13 @@ namespace app {
void Profiler::SetName(const char* str)
{
- this->_m_name = std::string(str);
+ this->m_name = std::string(str);
}
void Profiler::AddProfilingUnit(time_counter start, time_counter end,
const std::string& name)
{
- platform_timer * timer = this->_m_pPlatform->timer;
+ platform_timer * timer = this->m_pPlatform->timer;
struct ProfilingUnit unit;
@@ -269,7 +269,7 @@ namespace app {
unit.time = timer->get_duration_ms(&start, &end);
}
- this->_m_series[name].emplace_back(unit);
+ this->m_series[name].emplace_back(unit);
}
} /* namespace app */
diff --git a/source/application/main/include/AppContext.hpp b/source/application/main/include/AppContext.hpp
index 588dfaa..10de126 100644
--- a/source/application/main/include/AppContext.hpp
+++ b/source/application/main/include/AppContext.hpp
@@ -35,14 +35,14 @@ namespace app {
public:
~Attribute() override = default;
- explicit Attribute(const T value): _m_value(value){}
+ explicit Attribute(const T value): m_value(value){}
T Get()
{
- return _m_value;
+ return m_value;
}
private:
- T _m_value;
+ T m_value;
};
/* Application context class */
@@ -58,7 +58,7 @@ namespace app {
template<typename T>
void Set(const std::string &name, T object)
{
- this->_m_attributes[name] = new Attribute<T>(object);
+ this->m_attributes[name] = new Attribute<T>(object);
}
/**
@@ -70,7 +70,7 @@ namespace app {
template<typename T>
T Get(const std::string &name)
{
- auto a = (Attribute<T>*)_m_attributes[name];
+ auto a = (Attribute<T>*)m_attributes[name];
return a->Get();
}
@@ -81,19 +81,19 @@ namespace app {
*/
bool Has(const std::string& name)
{
- return _m_attributes.find(name) != _m_attributes.end();
+ return m_attributes.find(name) != m_attributes.end();
}
ApplicationContext() = default;
~ApplicationContext() {
- for (auto& attribute : _m_attributes)
+ for (auto& attribute : m_attributes)
delete attribute.second;
- this->_m_attributes.clear();
+ this->m_attributes.clear();
}
private:
- std::map<std::string, IAttribute*> _m_attributes;
+ std::map<std::string, IAttribute*> m_attributes;
};
} /* namespace app */
diff --git a/source/application/main/include/DataStructures.hpp b/source/application/main/include/DataStructures.hpp
index 2f267c0..d369cb6 100644
--- a/source/application/main/include/DataStructures.hpp
+++ b/source/application/main/include/DataStructures.hpp
@@ -47,39 +47,39 @@ namespace app {
* @param[in] rows Number of rows.
* @param[in] cols Number of columns.
*/
- Array2d(unsigned rows, unsigned cols): _m_rows(rows), _m_cols(cols)
+ Array2d(unsigned rows, unsigned cols): m_rows(rows), m_cols(cols)
{
if (rows == 0 || cols == 0) {
printf_err("Array2d constructor has 0 size.\n");
- _m_data = nullptr;
+ m_data = nullptr;
return;
}
- _m_data = new T[rows * cols];
+ m_data = new T[rows * cols];
}
~Array2d()
{
- delete[] _m_data;
+ delete[] m_data;
}
T& operator() (unsigned int row, unsigned int col)
{
#if defined(DEBUG)
- if (row >= _m_rows || col >= _m_cols || _m_data == nullptr) {
+ if (row >= m_rows || col >= m_cols || m_data == nullptr) {
printf_err("Array2d subscript out of bounds.\n");
}
#endif /* defined(DEBUG) */
- return _m_data[_m_cols * row + col];
+ return m_data[m_cols * row + col];
}
T operator() (unsigned int row, unsigned int col) const
{
#if defined(DEBUG)
- if (row >= _m_rows || col >= _m_cols || _m_data == nullptr) {
+ if (row >= m_rows || col >= m_cols || m_data == nullptr) {
printf_err("const Array2d subscript out of bounds.\n");
}
#endif /* defined(DEBUG) */
- return _m_data[_m_cols * row + col];
+ return m_data[m_cols * row + col];
}
/**
@@ -91,9 +91,9 @@ namespace app {
switch (dim)
{
case 0:
- return _m_rows;
+ return m_rows;
case 1:
- return _m_cols;
+ return m_cols;
default:
return 0;
}
@@ -104,7 +104,7 @@ namespace app {
*/
size_t totalSize()
{
- return _m_rows * _m_cols;
+ return m_rows * m_cols;
}
/**
@@ -113,15 +113,15 @@ namespace app {
using iterator=T*;
using const_iterator=T const*;
- iterator begin() { return _m_data; }
- iterator end() { return _m_data + totalSize(); }
- const_iterator begin() const { return _m_data; }
- const_iterator end() const { return _m_data + totalSize(); };
+ iterator begin() { return m_data; }
+ iterator end() { return m_data + totalSize(); }
+ const_iterator begin() const { return m_data; }
+ const_iterator end() const { return m_data + totalSize(); };
private:
- size_t _m_rows;
- size_t _m_cols;
- T* _m_data;
+ size_t m_rows;
+ size_t m_cols;
+ T* m_data;
};
} /* namespace app */
diff --git a/source/application/main/include/Mfcc.hpp b/source/application/main/include/Mfcc.hpp
index dcafe62..6b11ebb 100644
--- a/source/application/main/include/Mfcc.hpp
+++ b/source/application/main/include/Mfcc.hpp
@@ -104,14 +104,14 @@ namespace audio {
float minVal = std::numeric_limits<T>::min();
float maxVal = std::numeric_limits<T>::max();
- std::vector<T> mfccOut(this->_m_params.m_numMfccFeatures);
- const size_t numFbankBins = this->_m_params.m_numFbankBins;
+ std::vector<T> mfccOut(this->m_params.m_numMfccFeatures);
+ const size_t numFbankBins = this->m_params.m_numFbankBins;
/* Take DCT. Uses matrix mul. */
for (size_t i = 0, j = 0; i < mfccOut.size(); ++i, j += numFbankBins) {
float sum = 0;
for (size_t k = 0; k < numFbankBins; ++k) {
- sum += this->_m_dctMatrix[j + k] * this->_m_melEnergies[k];
+ sum += this->m_dctMatrix[j + k] * this->m_melEnergies[k];
}
/* Quantize to T. */
sum = std::round((sum / quantScale) + quantOffset);
@@ -131,7 +131,7 @@ namespace audio {
/**
* @brief Project input frequency to Mel Scale.
* @param[in] freq Input frequency in floating point.
- * @param[in] useHTKmethod bool to signal if HTK method is to be
+ * @param[in] useHTKMethod bool to signal if HTK method is to be
* used for calculation.
* @return Mel transformed frequency in floating point.
**/
@@ -141,8 +141,8 @@ namespace audio {
/**
* @brief Inverse Mel transform - convert MEL warped frequency
* back to normal frequency.
- * @param[in] freq Mel frequency in floating point.
- * @param[in] useHTKmethod bool to signal if HTK method is to be
+ * @param[in] melFreq Mel frequency in floating point.
+ * @param[in] useHTKMethod bool to signal if HTK method is to be
* used for calculation.
* @return Real world frequency in floating point.
**/
@@ -207,17 +207,17 @@ namespace audio {
bool useHTKMethod);
private:
- MfccParams _m_params;
- std::vector<float> _m_frame;
- std::vector<float> _m_buffer;
- std::vector<float> _m_melEnergies;
- std::vector<float> _m_windowFunc;
- std::vector<std::vector<float>> _m_melFilterBank;
- std::vector<float> _m_dctMatrix;
- std::vector<uint32_t> _m_filterBankFilterFirst;
- std::vector<uint32_t> _m_filterBankFilterLast;
- bool _m_filterBankInitialised;
- arm::app::math::FftInstance _m_fftInstance;
+ MfccParams m_params;
+ std::vector<float> m_frame;
+ std::vector<float> m_buffer;
+ std::vector<float> m_melEnergies;
+ std::vector<float> m_windowFunc;
+ std::vector<std::vector<float>> m_melFilterBank;
+ std::vector<float> m_dctMatrix;
+ std::vector<uint32_t> m_filterBankFilterFirst;
+ std::vector<uint32_t> m_filterBankFilterLast;
+ bool m_filterBankInitialised;
+ arm::app::math::FftInstance m_fftInstance;
/**
* @brief Initialises the filter banks and the DCT matrix. **/
diff --git a/source/application/main/include/Profiler.hpp b/source/application/main/include/Profiler.hpp
index c5f77e7..d1b6d91 100644
--- a/source/application/main/include/Profiler.hpp
+++ b/source/application/main/include/Profiler.hpp
@@ -107,14 +107,14 @@ namespace app {
void SetName(const char* str);
private:
- ProfilingMap _m_series; /* Profiling series map. */
- time_counter _m_tstampSt{}; /* Container for a current starting timestamp. */
- time_counter _m_tstampEnd{}; /* Container for a current ending timestamp. */
- hal_platform * _m_pPlatform = nullptr; /* Platform pointer - to get the timer. */
+ ProfilingMap m_series; /* Profiling series map. */
+ time_counter m_tstampSt{}; /* Container for a current starting timestamp. */
+ time_counter m_tstampEnd{}; /* Container for a current ending timestamp. */
+ hal_platform * m_pPlatform = nullptr; /* Platform pointer - to get the timer. */
- bool _m_started = false; /* Indicates profiler has been started. */
+ bool m_started = false; /* Indicates profiler has been started. */
- std::string _m_name; /* Name given to this profiler. */
+ std::string m_name; /* Name given to this profiler. */
/**
* @brief Appends the profiling unit computed by the "start" and
diff --git a/source/application/main/include/UseCaseCommonUtils.hpp b/source/application/main/include/UseCaseCommonUtils.hpp
index 7887aea..d328392 100644
--- a/source/application/main/include/UseCaseCommonUtils.hpp
+++ b/source/application/main/include/UseCaseCommonUtils.hpp
@@ -42,12 +42,11 @@ namespace app {
* @param[in] profiler Reference to the initialised profiler.
* @return true if inference succeeds, false otherwise.
**/
- bool RunInference(arm::app::Model& mode, Profiler& profiler);
+ bool RunInference(arm::app::Model& model, Profiler& profiler);
/**
* @brief Read input and return as an integer.
* @param[in] platform Reference to the hal platform object.
- * @param[in] model Reference to the initialised model.
* @return Integer value corresponding to the user input.
**/
int ReadUserInputAsInt(hal_platform& platform);
diff --git a/source/application/tensorflow-lite-micro/Model.cc b/source/application/tensorflow-lite-micro/Model.cc
index 4a7f0a4..e9c6cd3 100644
--- a/source/application/tensorflow-lite-micro/Model.cc
+++ b/source/application/tensorflow-lite-micro/Model.cc
@@ -24,8 +24,8 @@
/* Initialise the model */
arm::app::Model::~Model()
{
- if (this->_m_pInterpreter) {
- delete this->_m_pInterpreter;
+ if (this->m_pInterpreter) {
+ delete this->m_pInterpreter;
}
/**
@@ -34,10 +34,10 @@ arm::app::Model::~Model()
}
arm::app::Model::Model() :
- _m_inited (false),
- _m_type(kTfLiteNoType)
+ m_inited (false),
+ m_type(kTfLiteNoType)
{
- this->_m_pErrorReporter = &this->_m_uErrorReporter;
+ this->m_pErrorReporter = &this->m_uErrorReporter;
}
bool arm::app::Model::Init(tflite::MicroAllocator* allocator)
@@ -47,13 +47,13 @@ bool arm::app::Model::Init(tflite::MicroAllocator* allocator)
* copying or parsing, it's a very lightweight operation. */
const uint8_t* model_addr = ModelPointer();
debug("loading model from @ 0x%p\n", model_addr);
- this->_m_pModel = ::tflite::GetModel(model_addr);
+ this->m_pModel = ::tflite::GetModel(model_addr);
- if (this->_m_pModel->version() != TFLITE_SCHEMA_VERSION) {
- this->_m_pErrorReporter->Report(
+ if (this->m_pModel->version() != TFLITE_SCHEMA_VERSION) {
+ this->m_pErrorReporter->Report(
"[ERROR] model's schema version %d is not equal "
"to supported version %d.",
- this->_m_pModel->version(), TFLITE_SCHEMA_VERSION);
+ this->m_pModel->version(), TFLITE_SCHEMA_VERSION);
return false;
}
@@ -69,80 +69,80 @@ bool arm::app::Model::Init(tflite::MicroAllocator* allocator)
this->EnlistOperations();
/* Create allocator instance, if it doesn't exist */
- this->_m_pAllocator = allocator;
- if (!this->_m_pAllocator) {
+ this->m_pAllocator = allocator;
+ if (!this->m_pAllocator) {
/* Create an allocator instance */
info("Creating allocator using tensor arena in %s\n",
ACTIVATION_BUF_SECTION_NAME);
- this->_m_pAllocator = tflite::MicroAllocator::Create(
+ this->m_pAllocator = tflite::MicroAllocator::Create(
this->GetTensorArena(),
this->GetActivationBufferSize(),
- this->_m_pErrorReporter);
+ this->m_pErrorReporter);
- if (!this->_m_pAllocator) {
+ if (!this->m_pAllocator) {
printf_err("Failed to create allocator\n");
return false;
}
- debug("Created new allocator @ 0x%p\n", this->_m_pAllocator);
+ debug("Created new allocator @ 0x%p\n", this->m_pAllocator);
} else {
- debug("Using existing allocator @ 0x%p\n", this->_m_pAllocator);
+ debug("Using existing allocator @ 0x%p\n", this->m_pAllocator);
}
- this->_m_pInterpreter = new ::tflite::MicroInterpreter(
- this->_m_pModel, this->GetOpResolver(),
- this->_m_pAllocator, this->_m_pErrorReporter);
+ this->m_pInterpreter = new ::tflite::MicroInterpreter(
+ this->m_pModel, this->GetOpResolver(),
+ this->m_pAllocator, this->m_pErrorReporter);
- if (!this->_m_pInterpreter) {
+ if (!this->m_pInterpreter) {
printf_err("Failed to allocate interpreter\n");
return false;
}
/* Allocate memory from the tensor_arena for the model's tensors. */
info("Allocating tensors\n");
- TfLiteStatus allocate_status = this->_m_pInterpreter->AllocateTensors();
+ TfLiteStatus allocate_status = this->m_pInterpreter->AllocateTensors();
if (allocate_status != kTfLiteOk) {
- this->_m_pErrorReporter->Report("[ERROR] allocateTensors() failed");
+ this->m_pErrorReporter->Report("[ERROR] allocateTensors() failed");
printf_err("tensor allocation failed!\n");
- delete this->_m_pInterpreter;
+ delete this->m_pInterpreter;
return false;
}
/* Get information about the memory area to use for the model's input. */
- this->_m_input.resize(this->GetNumInputs());
+ this->m_input.resize(this->GetNumInputs());
for (size_t inIndex = 0; inIndex < this->GetNumInputs(); inIndex++)
- this->_m_input[inIndex] = this->_m_pInterpreter->input(inIndex);
+ this->m_input[inIndex] = this->m_pInterpreter->input(inIndex);
- this->_m_output.resize(this->GetNumOutputs());
+ this->m_output.resize(this->GetNumOutputs());
for (size_t outIndex = 0; outIndex < this->GetNumOutputs(); outIndex++)
- this->_m_output[outIndex] = this->_m_pInterpreter->output(outIndex);
+ this->m_output[outIndex] = this->m_pInterpreter->output(outIndex);
- if (this->_m_input.empty() || this->_m_output.empty()) {
+ if (this->m_input.empty() || this->m_output.empty()) {
printf_err("failed to get tensors\n");
return false;
} else {
- this->_m_type = this->_m_input[0]->type; /* Input 0 should be the main input */
+ this->m_type = this->m_input[0]->type; /* Input 0 should be the main input */
/* Clear the input & output tensors */
for (size_t inIndex = 0; inIndex < this->GetNumInputs(); inIndex++) {
- std::memset(this->_m_input[inIndex]->data.data, 0, this->_m_input[inIndex]->bytes);
+ std::memset(this->m_input[inIndex]->data.data, 0, this->m_input[inIndex]->bytes);
}
for (size_t outIndex = 0; outIndex < this->GetNumOutputs(); outIndex++) {
- std::memset(this->_m_output[outIndex]->data.data, 0, this->_m_output[outIndex]->bytes);
+ std::memset(this->m_output[outIndex]->data.data, 0, this->m_output[outIndex]->bytes);
}
this->LogInterpreterInfo();
}
- this->_m_inited = true;
+ this->m_inited = true;
return true;
}
tflite::MicroAllocator* arm::app::Model::GetAllocator()
{
if (this->IsInited()) {
- return this->_m_pAllocator;
+ return this->m_pAllocator;
}
return nullptr;
}
@@ -178,31 +178,31 @@ void arm::app::Model::LogTensorInfo(TfLiteTensor* tensor)
void arm::app::Model::LogInterpreterInfo()
{
- if (!this->_m_pInterpreter) {
+ if (!this->m_pInterpreter) {
printf_err("Invalid interpreter\n");
return;
}
info("Model INPUT tensors: \n");
- for (auto input : this->_m_input) {
+ for (auto input : this->m_input) {
this->LogTensorInfo(input);
}
info("Model OUTPUT tensors: \n");
- for (auto output : this->_m_output) {
+ for (auto output : this->m_output) {
this->LogTensorInfo(output);
}
info("Activation buffer (a.k.a tensor arena) size used: %zu\n",
- this->_m_pInterpreter->arena_used_bytes());
+ this->m_pInterpreter->arena_used_bytes());
- const size_t nOperators = this->_m_pInterpreter->operators_size();
+ const size_t nOperators = this->m_pInterpreter->operators_size();
info("Number of operators: %zu\n", nOperators);
/* For each operator, display registration information */
for (size_t i = 0 ; i < nOperators; ++i) {
const tflite::NodeAndRegistration nodeReg =
- this->_m_pInterpreter->node_and_registration(i);
+ this->m_pInterpreter->node_and_registration(i);
const TfLiteRegistration* reg = nodeReg.registration;
std::string opName{""};
@@ -220,7 +220,7 @@ void arm::app::Model::LogInterpreterInfo()
bool arm::app::Model::IsInited() const
{
- return this->_m_inited;
+ return this->m_inited;
}
bool arm::app::Model::IsDataSigned() const
@@ -231,8 +231,8 @@ bool arm::app::Model::IsDataSigned() const
bool arm::app::Model::RunInference()
{
bool inference_state = false;
- if (this->_m_pModel && this->_m_pInterpreter) {
- if (kTfLiteOk != this->_m_pInterpreter->Invoke()) {
+ if (this->m_pModel && this->m_pInterpreter) {
+ if (kTfLiteOk != this->m_pInterpreter->Invoke()) {
printf_err("Invoke failed.\n");
} else {
inference_state = true;
@@ -246,7 +246,7 @@ bool arm::app::Model::RunInference()
TfLiteTensor* arm::app::Model::GetInputTensor(size_t index) const
{
if (index < this->GetNumInputs()) {
- return this->_m_input.at(index);
+ return this->m_input.at(index);
}
return nullptr;
}
@@ -254,23 +254,23 @@ TfLiteTensor* arm::app::Model::GetInputTensor(size_t index) const
TfLiteTensor* arm::app::Model::GetOutputTensor(size_t index) const
{
if (index < this->GetNumOutputs()) {
- return this->_m_output.at(index);
+ return this->m_output.at(index);
}
return nullptr;
}
size_t arm::app::Model::GetNumInputs() const
{
- if (this->_m_pModel && this->_m_pInterpreter) {
- return this->_m_pInterpreter->inputs_size();
+ if (this->m_pModel && this->m_pInterpreter) {
+ return this->m_pInterpreter->inputs_size();
}
return 0;
}
size_t arm::app::Model::GetNumOutputs() const
{
- if (this->_m_pModel && this->_m_pInterpreter) {
- return this->_m_pInterpreter->outputs_size();
+ if (this->m_pModel && this->m_pInterpreter) {
+ return this->m_pInterpreter->outputs_size();
}
return 0;
}
@@ -278,13 +278,13 @@ size_t arm::app::Model::GetNumOutputs() const
TfLiteType arm::app::Model::GetType() const
{
- return this->_m_type;
+ return this->m_type;
}
TfLiteIntArray* arm::app::Model::GetInputShape(size_t index) const
{
if (index < this->GetNumInputs()) {
- return this->_m_input.at(index)->dims;
+ return this->m_input.at(index)->dims;
}
return nullptr;
}
@@ -292,7 +292,7 @@ TfLiteIntArray* arm::app::Model::GetInputShape(size_t index) const
TfLiteIntArray* arm::app::Model::GetOutputShape(size_t index) const
{
if (index < this->GetNumOutputs()) {
- return this->_m_output.at(index)->dims;
+ return this->m_output.at(index)->dims;
}
return nullptr;
}
diff --git a/source/application/tensorflow-lite-micro/include/Model.hpp b/source/application/tensorflow-lite-micro/include/Model.hpp
index 70cf9ca..7a0493c 100644
--- a/source/application/tensorflow-lite-micro/include/Model.hpp
+++ b/source/application/tensorflow-lite-micro/include/Model.hpp
@@ -123,16 +123,16 @@ namespace app {
size_t GetActivationBufferSize();
private:
- tflite::MicroErrorReporter _m_uErrorReporter; /* Error reporter object. */
- tflite::ErrorReporter* _m_pErrorReporter = nullptr; /* Pointer to the error reporter. */
- const tflite::Model* _m_pModel = nullptr; /* Tflite model pointer. */
- tflite::MicroInterpreter* _m_pInterpreter = nullptr; /* Tflite interpreter. */
- tflite::MicroAllocator* _m_pAllocator = nullptr; /* Tflite micro allocator. */
- bool _m_inited = false; /* Indicates whether this object has been initialised. */
-
- std::vector<TfLiteTensor*> _m_input = {}; /* Model's input tensor pointers. */
- std::vector<TfLiteTensor*> _m_output = {}; /* Model's output tensor pointers. */
- TfLiteType _m_type = kTfLiteNoType;/* Model's data type. */
+ tflite::MicroErrorReporter m_uErrorReporter; /* Error reporter object. */
+ tflite::ErrorReporter* m_pErrorReporter = nullptr; /* Pointer to the error reporter. */
+ const tflite::Model* m_pModel = nullptr; /* Tflite model pointer. */
+ tflite::MicroInterpreter* m_pInterpreter = nullptr; /* Tflite interpreter. */
+ tflite::MicroAllocator* m_pAllocator = nullptr; /* Tflite micro allocator. */
+ bool m_inited = false; /* Indicates whether this object has been initialised. */
+
+ std::vector<TfLiteTensor*> m_input = {}; /* Model's input tensor pointers. */
+ std::vector<TfLiteTensor*> m_output = {}; /* Model's output tensor pointers. */
+ TfLiteType m_type = kTfLiteNoType;/* Model's data type. */
};