summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-04-08 09:54:53 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2022-04-08 12:30:28 +0100
commit4cc4021d356c174f780be2b7ef96910e36c8dd7b (patch)
treec2a790b914577873a368982a07a9491f6743443e
parent11b75cc7dc140119dee490f425e25a004122703b (diff)
downloadml-embedded-evaluation-kit-4cc4021d356c174f780be2b7ef96910e36c8dd7b.tar.gz
MLECO-3070: Further HAL cleanup.
Cleaning up HAL sources by removing unnecessary redirections with function pointers. The "platform packages" under HAL are now streamlined enough to not need any major HAL wrapping (as was the case before). This allows us to have a very thin HAL layer that sits on top of the platform and compnent packs. Also helps in getting rid of "hal platform" pointer being passed around in the code to use any HAL functionality. Change-Id: I04b2057f972aad7a5cfb4a396bcdf147c9f9ef1c Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
-rw-r--r--docs/documentation.md4
-rw-r--r--docs/sections/customizing.md80
-rw-r--r--source/application/main/Main.cc14
-rw-r--r--source/hal/CMakeLists.txt2
-rw-r--r--source/hal/include/hal.h30
-rw-r--r--source/hal/include/hal_pmu.h (renamed from source/hal/include/timer.h)28
-rw-r--r--source/hal/source/components/npu/ethosu_profiler.c12
-rw-r--r--source/hal/source/components/npu/include/ethosu_profiler.h8
-rw-r--r--source/hal/source/components/platform_pmu/include/platform_pmu.h6
-rw-r--r--source/hal/source/hal.c55
-rw-r--r--source/hal/source/hal_pmu.c (renamed from source/hal/source/hal_timer.c)28
-rw-r--r--source/hal/source/platform/mps3/include/platform_drivers.h7
-rw-r--r--source/hal/source/platform/mps3/include/timer_mps3.h6
-rw-r--r--source/hal/source/platform/mps3/source/platform_drivers.c10
-rw-r--r--source/hal/source/platform/mps3/source/timer_mps3.c28
-rw-r--r--source/hal/source/platform/native/include/platform_drivers.h7
-rw-r--r--source/hal/source/platform/native/include/timer_native.h6
-rw-r--r--source/hal/source/platform/native/source/platform_drivers.c6
-rw-r--r--source/hal/source/platform/native/source/timer_native.c18
-rw-r--r--source/hal/source/platform/simple/include/platform_drivers.h7
-rw-r--r--source/hal/source/platform/simple/include/timer_simple_platform.h6
-rw-r--r--source/hal/source/platform/simple/source/platform_drivers.c9
-rw-r--r--source/hal/source/platform/simple/source/timer_simple_platform.c18
-rw-r--r--source/profiler/Profiler.cc52
-rw-r--r--source/profiler/include/Profiler.hpp10
-rw-r--r--source/use_case/ad/src/MainLoop.cc5
-rw-r--r--source/use_case/asr/src/MainLoop.cc5
-rw-r--r--source/use_case/img_class/src/MainLoop.cc5
-rw-r--r--source/use_case/inference_runner/src/MainLoop.cc6
-rw-r--r--source/use_case/kws/src/MainLoop.cc6
-rw-r--r--source/use_case/kws_asr/src/MainLoop.cc6
-rw-r--r--source/use_case/noise_reduction/src/MainLoop.cc6
-rw-r--r--source/use_case/object_detection/src/MainLoop.cc5
-rw-r--r--source/use_case/vww/src/MainLoop.cc5
-rw-r--r--tests/common/ProfilerTests.cc22
-rw-r--r--tests/use_case/img_class/ImgClassificationUCTest.cc26
-rw-r--r--tests/use_case/kws/KWSHandlerTest.cc27
-rw-r--r--tests/use_case/noise_reduction/RNNNoiseUCTests.cc9
-rw-r--r--tests/use_case/object_detection/ObjectDetectionUCTest.cc26
-rw-r--r--tests/use_case/vww/VisualWakeWordUCTests.cc26
40 files changed, 217 insertions, 425 deletions
diff --git a/docs/documentation.md b/docs/documentation.md
index 3e7a5c4..b391092 100644
--- a/docs/documentation.md
+++ b/docs/documentation.md
@@ -170,7 +170,7 @@ hal
├── include
│ ├── hal.h
│ ├── hal_lcd.h
-│ └── timer.h
+│ └── hal_pmu.h
└── source
├── components
│ ├── cmsis_device
@@ -180,7 +180,7 @@ hal
│ ├── platform_pmu
│ └── stdout
├── hal.c
- ├── hal_timer.c
+ ├── hal_pmu.c
└── platform
├── mps3
├── native
diff --git a/docs/sections/customizing.md b/docs/sections/customizing.md
index 604e708..5b822db 100644
--- a/docs/sections/customizing.md
+++ b/docs/sections/customizing.md
@@ -91,53 +91,15 @@ use-cases, sources are in the `use-case` subfolder.
The HAL is represented by the following interfaces. To access them, include the `hal.h` header.
-- `hal_platform` structure: Defines a platform context to be used by the application.
-
- | Attribute name | Description |
- |--------------------|----------------------------------------------------------------------------------------------|
- | `inited` | Initialization flag. Is set after the `platform_init()` function is called. |
- | `plat_name` | Platform name. it is set to `mps3-bare` for MPS3 build and `FVP` for Fast Model build. |
- | `timer` | Pointer to platform timer implementation (see `platform_timer`) |
- | `platform_init` | Pointer to platform initialization function. |
- | `platform_release` | Pointer to platform release function |
-
-- `hal_init` function: Initializes the HAL structure based on the compile-time configuration. This must be called before
- any other function in this API.
-
- | Parameter name | Description|
- |------------------|-----------------------------------------------------|
- | `platform` | Pointer to a pre-allocated `hal_platform` struct. |
- | `timer` | Pointer to a pre-allocated timer module |
- | `return` | Zero returned if successful, an error code is returned if unsuccessful. |
-
- `hal_platform_init` function: Initializes the HAL platform and every module on the platform that the application
requires to run.
- | Parameter name | Description |
- | ----------------| ------------------------------------------------------------------- |
- | `platform` | Pointer to a pre-allocated and initialized `hal_platform` struct. |
- | `return` | zero if successful, error code otherwise. |
+ | Parameter name | Description |
+ |--------------------------------------| ------------------------------------------------------------------- |
+ | `return` | true if successful, false otherwise. |
- `hal_platform_release` function Releases the HAL platform and any acquired resources.
- | Parameter name | Description |
- | ----------------| ------------------------------------------------------------------- |
- | `platform` | Pointer to a pre-allocated and initialized `hal_platform` struct. |
-
-- `platform_timer` structure: The structure to hold a platform-specific timer implementation.
-
- | Attribute name | Description |
- |---------------------|------------------------------------------------|
- | `inited` | Initialization flag. It is set after the timer is initialized by the `hal_platform_init` function. |
- | `reset` | Pointer to a function to reset a timer. |
- | `get_time_counter` | Pointer to a function to get current time counter. |
- | `get_duration_ms` | Pointer to a function to calculate duration between two time-counters in milliseconds. |
- | `get_duration_us` | Pointer to a function to calculate duration between two time-counters in microseconds |
- | `get_cpu_cycle_diff` | Pointer to a function to calculate duration between two time-counters in *Cortex-M55* cycles. |
- | `get_npu_cycle_diff` | Pointer to a function to calculate duration between two time-counters in *Ethos-U* cycles. Available only when project is configured with `ETHOS_U_NPU_ENABLED` set. |
- | `start_profiling` | If necessary, wraps the `get_time_counter` function with another profiling initialization, if necessary. |
- | `stop_profiling` | If necessary, wraps the `get_time_counter` function along with more instructions when profiling ends. |
-
An example of the API initialization in the main function:
```C++
@@ -146,20 +108,13 @@ An example of the API initialization in the main function:
int main ()
{
-
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
...
- hal_platform_release(&platform);
-
+ hal_platform_release();
return 0;
-
}
```
@@ -168,13 +123,12 @@ int main ()
Code samples application main function delegates the use-case logic execution to the main loop function that must be
implemented for each custom ML scenario.
-Main loop function takes the initialized `hal_platform` structure pointer as an argument.
-
The main loop function has external linkage and the main executable for the use-case references the function defined in
the use-case code.
```C++
-void main_loop(hal_platform& platform){
+void main_loop()
+{
...
@@ -198,17 +152,16 @@ For example:
#include "hal.h"
#include "AppContext.hpp"
-void main_loop(hal_platform& platform) {
-
+void main_loop()
+{
/* Instantiate application context */
arm::app::ApplicationContext caseContext;
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<uint32_t>("counter", 0);
/* loop */
- while (true) {
- // do something, pass application context down the call stack
- }
+ while (true) {
+ // do something, pass application context down the call stack
+ }
}
```
@@ -230,7 +183,8 @@ It uses platform timer to get system timing information.
An example of it in use:
```C++
-Profiler profiler{&platform, "Inference"};
+/* A named profiler instance */
+Profiler profiler{"Inference"};
profiler.StartProfiling();
// Code running inference to profile
@@ -331,7 +285,7 @@ Now define the `main_loop` function with the signature described in [Main loop f
#include "hal.h"
#include "log_macros.h"
-void main_loop(hal_platform& platform) {
+void main_loop() {
printf("Hello world!");
}
```
@@ -474,7 +428,7 @@ The following code adds inference invocation to the main loop function:
#include "HelloWorldModel.hpp"
#include "log_macros.h"
- void main_loop(hal_platform& platform) {
+ void main_loop() {
/* model wrapper object */
arm::app::HelloWorldModel model;
@@ -549,7 +503,7 @@ To add profiling for the *Ethos-U*, include a `Profiler.hpp` header and invoke b
For example:
```C++
-Profiler profiler{&platform, "Inference"};
+Profiler profiler{"Inference"};
profiler.StartProfiling();
model.RunInference();
diff --git a/source/application/main/Main.cc b/source/application/main/Main.cc
index e27d5b5..4b1f8f4 100644
--- a/source/application/main/Main.cc
+++ b/source/application/main/Main.cc
@@ -25,7 +25,7 @@
#include <cstdio>
-extern void main_loop(hal_platform& platform);
+extern void main_loop();
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
__ASM(" .global __ARM_use_no_argv\n");
@@ -41,13 +41,7 @@ static void print_application_intro()
int main ()
{
- hal_platform platform;
- platform_timer timer;
-
- /* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
-
- if (0 == hal_platform_init(&platform)) {
+ if (hal_platform_init()) {
/* Application information, UART should have been initialised. */
print_application_intro();
@@ -55,13 +49,13 @@ int main ()
PrintTensorFlowVersion();
/* Run the application. */
- main_loop(platform);
+ main_loop();
}
/* This is unreachable without errors. */
info("program terminating...\n");
/* Release platform. */
- hal_platform_release(&platform);
+ hal_platform_release();
return 0;
}
diff --git a/source/hal/CMakeLists.txt b/source/hal/CMakeLists.txt
index 37bf267..74256bb 100644
--- a/source/hal/CMakeLists.txt
+++ b/source/hal/CMakeLists.txt
@@ -39,7 +39,7 @@ target_include_directories(${HAL_TARGET}
target_sources(${HAL_TARGET}
PRIVATE
source/hal.c
- source/hal_timer.c)
+ source/hal_pmu.c)
if (DEFINED VERIFY_TEST_OUTPUT)
message(STATUS "Test output verification flag is: ${VERIFY_TEST_OUTPUT}")
diff --git a/source/hal/include/hal.h b/source/hal/include/hal.h
index 25ea1e2..5d1964d 100644
--- a/source/hal/include/hal.h
+++ b/source/hal/include/hal.h
@@ -29,47 +29,25 @@ extern "C" {
#endif
#include "platform_drivers.h" /* Platform drivers */
-#include "timer.h" /* Timer/profiler API */
+#include "hal_pmu.h" /* Timer/profiler API */
#include "hal_lcd.h" /* LCD functions */
#include <inttypes.h>
#include <stdbool.h>
-/* Structure to define a platform context to be used by the application */
-typedef struct hal_platform_context {
- int inited; /**< initialised */
- char plat_name[64]; /**< name of this platform */
- platform_timer* timer; /**< timer */
- int (* platform_init)(); /**< pointer to platform initialisation function */
- void (* platform_release)(); /**< pointer to platform release function */
-} hal_platform;
-
-/**
- * @brief Initialise the HAL structure based on compile time config. This
- * should be called before any other function in this API.
- * @param[in,out] platform Pointer to a pre-allocated platform struct.
- * @param[in,out] timer Pointer to a pre-allocated timer module.
- * @return 0 if successful, error code otherwise.
- **/
-int hal_init(hal_platform* platform, platform_timer* timer);
-
-
/**
* @brief Initialise the HAL platform. This will go and initialise all the
* modules on the platform the application requires to run.
- * @param[in] platform Pointer to a pre-allocated and initialised
- * platform structure.
- * @return 0 if successful, error code otherwise.
+ * @return True if successful, false otherwise.
**/
-int hal_platform_init(hal_platform* platform);
+bool hal_platform_init(void);
/**
* @brief Release the HAL platform. This should release resources acquired.
- * @param[in] platform pointer to a pre-allocated and initialised
* platform structure.
**/
-void hal_platform_release(hal_platform* platform);
+void hal_platform_release(void);
/**
* @brief Gets user input from the stdin interface.
diff --git a/source/hal/include/timer.h b/source/hal/include/hal_pmu.h
index 9910fcf..5bfe517 100644
--- a/source/hal/include/timer.h
+++ b/source/hal/include/hal_pmu.h
@@ -14,23 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef HAL_TIMER_H
-#define HAL_TIMER_H
+#ifndef HAL_PMU_H
+#define HAL_PMU_H
-#include "platform_drivers.h" /* Platform package API */
-#include "user_input.h" /* PMU structs and API */
+#include "platform_pmu.h"
-/* Structure to hold a platform specific timer implementation */
-typedef struct _platform_timer {
- int inited; /**< Initialised or not. */
- void (* reset)(void); /**< Reset the timer. */
- pmu_counters (* get_counters)(void); /**< Gets the current time counter. */
+/**
+ * @brief Initialise the PMU available for the platform.
+ **/
+void hal_pmu_init(void);
-} platform_timer;
+/**
+ * @brief Resets the counters.
+ */
+void hal_pmu_reset(void);
/**
- * @brief Initialise the timer available for the platform.
+ * @brief Gets the current counter values.
+ * @param[out] Pointer to a pmu_counters object.
**/
-void init_timer(platform_timer* timer);
+void hal_pmu_get_counters(pmu_counters* counters);
-#endif /* HAL_TIMER_H */
+#endif /* HAL_PMU_H */
diff --git a/source/hal/source/components/npu/ethosu_profiler.c b/source/hal/source/components/npu/ethosu_profiler.c
index 3ac3497..5d50b09 100644
--- a/source/hal/source/components/npu/ethosu_profiler.c
+++ b/source/hal/source/components/npu/ethosu_profiler.c
@@ -22,6 +22,8 @@
extern struct ethosu_driver ethosu_drv; /* Default Arm Ethos-U NPU device driver object */
static ethosu_pmu_counters npu_counters; /* NPU counter local instance */
+static const char* unit_beats = "beats";
+static const char* unit_cycles = "cycles";
/**
* @brief Gets the npu counter instance to be used.
@@ -59,29 +61,29 @@ void ethosu_pmu_init(void)
counters->npu_evt_counters[0].event_type = ETHOSU_PMU_NPU_IDLE;
counters->npu_evt_counters[0].event_mask = ETHOSU_PMU_CNT1_Msk;
counters->npu_evt_counters[0].name = "NPU IDLE";
- counters->npu_evt_counters[0].unit = "cycles";
+ counters->npu_evt_counters[0].unit = unit_cycles;
counters->npu_evt_counters[1].event_type = ETHOSU_PMU_AXI0_RD_DATA_BEAT_RECEIVED;
counters->npu_evt_counters[1].event_mask = ETHOSU_PMU_CNT2_Msk;
counters->npu_evt_counters[1].name = "NPU AXI0_RD_DATA_BEAT_RECEIVED";
- counters->npu_evt_counters[1].unit = "beats";
+ counters->npu_evt_counters[1].unit = unit_beats;
counters->npu_evt_counters[2].event_type = ETHOSU_PMU_AXI0_WR_DATA_BEAT_WRITTEN;
counters->npu_evt_counters[2].event_mask = ETHOSU_PMU_CNT3_Msk;
counters->npu_evt_counters[2].name = "NPU AXI0_WR_DATA_BEAT_WRITTEN";
- counters->npu_evt_counters[2].unit = "beats";
+ counters->npu_evt_counters[2].unit = unit_beats;
counters->npu_evt_counters[3].event_type = ETHOSU_PMU_AXI1_RD_DATA_BEAT_RECEIVED;
counters->npu_evt_counters[3].event_mask = ETHOSU_PMU_CNT4_Msk;
counters->npu_evt_counters[3].name = "NPU AXI1_RD_DATA_BEAT_RECEIVED";
- counters->npu_evt_counters[3].unit = "beats";
+ counters->npu_evt_counters[3].unit = unit_beats;
#else /* ETHOSU_PMU_NCOUNTERS >= 4 */
#error "NPU PMU expects a minimum of 4 available event triggered counters!"
#endif /* ETHOSU_PMU_NCOUNTERS >= 4 */
#if ETHOSU_DERIVED_NCOUNTERS >= 1
counters->npu_derived_counters[0].name = "NPU ACTIVE";
- counters->npu_derived_counters[0].unit = "cycles";
+ counters->npu_derived_counters[0].unit = unit_cycles;
#endif /* ETHOSU_DERIVED_NCOUNTERS >= 1 */
for (i = 0; i < ETHOSU_PMU_NCOUNTERS; ++i) {
diff --git a/source/hal/source/components/npu/include/ethosu_profiler.h b/source/hal/source/components/npu/include/ethosu_profiler.h
index ca95b19..093c07f 100644
--- a/source/hal/source/components/npu/include/ethosu_profiler.h
+++ b/source/hal/source/components/npu/include/ethosu_profiler.h
@@ -29,14 +29,14 @@ typedef struct npu_event_counter_ {
enum ethosu_pmu_event_type event_type;
uint32_t event_mask;
uint32_t counter_value;
- char* unit;
- char* name;
+ const char* unit;
+ const char* name;
} npu_evt_counter;
typedef struct npu_derived_counter_ {
uint32_t counter_value;
- char* unit;
- char* name;
+ const char* unit;
+ const char* name;
} npu_derived_counter;
typedef struct ethosu_pmu_counters_ {
diff --git a/source/hal/source/components/platform_pmu/include/platform_pmu.h b/source/hal/source/components/platform_pmu/include/platform_pmu.h
index 3724e57..b3fd8e8 100644
--- a/source/hal/source/components/platform_pmu/include/platform_pmu.h
+++ b/source/hal/source/components/platform_pmu/include/platform_pmu.h
@@ -50,10 +50,10 @@ typedef struct _pmu_counters {
void platform_reset_counters(void);
/**
- * @brief Gets the current counter values.
- * @returns A populated instance of pmu_counters struct.
+ * @brief Gets the current counter values.
+ * @param[out] Pointer to a pmu_counters object.
**/
-pmu_counters platform_get_counters(void);
+void platform_get_counters(pmu_counters* counters);
#ifdef __cplusplus
}
diff --git a/source/hal/source/hal.c b/source/hal/source/hal.c
index d6028e7..4651bfd 100644
--- a/source/hal/source/hal.c
+++ b/source/hal/source/hal.c
@@ -19,62 +19,29 @@
#include "platform_drivers.h" /* Platform drivers */
#include "log_macros.h" /* Logging macros */
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-
-int hal_init(hal_platform* platform, platform_timer* timer)
-{
- platform->timer = timer;
- platform->platform_init = platform_init;
- platform->platform_release = platform_release;
- platform_name(platform->plat_name, sizeof(platform->plat_name));
-
- return 0;
-}
-
-/**
- * @brief Local helper function to clean the slate for current platform.
- **/
-static void hal_platform_clear(hal_platform* platform)
+bool hal_platform_init(void)
{
- assert(platform);
- platform->inited = 0;
-}
-
-int hal_platform_init(hal_platform* platform)
-{
- int state;
- assert(platform && platform->platform_init);
- hal_platform_clear(platform);
-
/* Initialise platform */
- if (0 != (state = platform->platform_init())) {
- printf_err("Failed to initialise platform %s\n", platform->plat_name);
- return state;
+ if (0 != platform_init()) {
+ printf_err("Failed to initialise platform %s\n", platform_name());
+ return false;
}
/* Initialise LCD */
- if (0 != (state = hal_lcd_init())) {
+ if (0 != hal_lcd_init()) {
printf_err("hal_lcd_init failed\n");
- return state;
+ return false;
}
- /* Initialise the timer module */
- init_timer(platform->timer);
+ /* Initialise PMU */
+ hal_pmu_init();
- info("%s platform initialised\n", platform->plat_name);
- platform->inited = !state;
- return state;
+ return true;
}
-void hal_platform_release(hal_platform *platform)
+void hal_platform_release(void)
{
- assert(platform && platform->platform_release);
-
- hal_platform_clear(platform);
- info("Releasing platform %s\n", platform->plat_name);
- platform->platform_release();
+ platform_release();
}
bool hal_get_user_input(char* user_input, int size)
diff --git a/source/hal/source/hal_timer.c b/source/hal/source/hal_pmu.c
index 0488afa..c89128d 100644
--- a/source/hal/source/hal_timer.c
+++ b/source/hal/source/hal_pmu.c
@@ -14,26 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include "timer.h"
-#include "log_macros.h"
+#include "hal_pmu.h"
#include "platform_drivers.h"
-#include <assert.h>
-#include <string.h>
-#include <inttypes.h>
-
-/**
- * @brief Initialiser for HAL timer.
- * @param[in] timer Platform timer to initialize.
- **/
-void init_timer(platform_timer* timer)
+void hal_pmu_init(void)
{
- assert(timer);
- memset(timer, 0, sizeof(*timer));
+ platform_reset_counters();
+}
- timer->reset = platform_reset_counters;
- timer->get_counters = platform_get_counters;
+void hal_pmu_reset(void)
+{
+ platform_reset_counters();
+}
- timer->reset();
- timer->inited = 1;
+void hal_pmu_get_counters(pmu_counters* counters)
+{
+ platform_get_counters(counters);
}
diff --git a/source/hal/source/platform/mps3/include/platform_drivers.h b/source/hal/source/platform/mps3/include/platform_drivers.h
index 8b699d5..de03bcd 100644
--- a/source/hal/source/platform/mps3/include/platform_drivers.h
+++ b/source/hal/source/platform/mps3/include/platform_drivers.h
@@ -38,10 +38,9 @@ int platform_init(void);
void platform_release(void);
/**
- * @brief Sets the platform name.
- * @param[out] name Name of the platform to be set
- * @param[in] size Size of the input buffer
+ * @brief Gets the platform name.
+ * @return Pointer to the name
*/
-void platform_name(char* name, size_t size);
+const char* platform_name(void);
#endif /* PLATFORM_DRIVERS_H */
diff --git a/source/hal/source/platform/mps3/include/timer_mps3.h b/source/hal/source/platform/mps3/include/timer_mps3.h
index b370e89..dcec980 100644
--- a/source/hal/source/platform/mps3/include/timer_mps3.h
+++ b/source/hal/source/platform/mps3/include/timer_mps3.h
@@ -44,10 +44,10 @@ typedef struct mps3_pmu_counters_ {
void platform_reset_counters(void);
/**
- * @brief Gets the current counter values.
- * @returns A populated instance of pmu_counters struct.
+ * @brief Gets the current counter values.
+ * @param[out] Pointer to a pmu_counters object.
**/
-pmu_counters platform_get_counters(void);
+void platform_get_counters(pmu_counters* counters);
/**
* @brief Gets the MPS3 core clock
diff --git a/source/hal/source/platform/mps3/source/platform_drivers.c b/source/hal/source/platform/mps3/source/platform_drivers.c
index 17ccdf2..d1c3da2 100644
--- a/source/hal/source/platform/mps3/source/platform_drivers.c
+++ b/source/hal/source/platform/mps3/source/platform_drivers.c
@@ -48,6 +48,9 @@
*/
static int verify_platform(void);
+/** Platform name */
+static const char* s_platform_name = DESIGN_NAME;
+
int platform_init(void)
{
int err = 0;
@@ -82,8 +85,7 @@ int platform_init(void)
#endif /* ARM_NPU */
/* Print target design info */
- info("Target system design: %s\n", DESIGN_NAME);
-
+ info("Target system design: %s\n", s_platform_name);
return 0;
}
@@ -92,9 +94,9 @@ void platform_release(void)
__disable_irq();
}
-void platform_name(char* name, size_t size)
+const char* platform_name(void)
{
- strncpy(name, DESIGN_NAME, size);
+ return s_platform_name;
}
#define CREATE_MASK(msb, lsb) (int)(((1U << ((msb) - (lsb) + 1)) - 1) << (lsb))
diff --git a/source/hal/source/platform/mps3/source/timer_mps3.c b/source/hal/source/platform/mps3/source/timer_mps3.c
index 6330269..7ce3002 100644
--- a/source/hal/source/platform/mps3/source/timer_mps3.c
+++ b/source/hal/source/platform/mps3/source/timer_mps3.c
@@ -20,6 +20,8 @@
#include "smm_mps3.h" /* Memory map for MPS3. */
static uint64_t cpu_cycle_count = 0; /* 64-bit cpu cycle counter */
+static const char* unit_cycles = "cycles";
+static const char* unit_ms = "milliseconds";
/**
* @brief Gets the system tick triggered cycle counter for the CPU.
@@ -69,12 +71,10 @@ void platform_reset_counters(void)
#endif /* defined (ARM_NPU) */
}
-pmu_counters platform_get_counters(void)
+void platform_get_counters(pmu_counters* counters)
{
- pmu_counters platform_counters = {
- .num_counters = 0,
- .initialised = true
- };
+ counters->num_counters = 0;
+ counters->initialised = true;
uint32_t i = 0;
#if defined (ARM_NPU)
@@ -84,20 +84,20 @@ pmu_counters platform_get_counters(void)
npu_counters.npu_evt_counters[i].counter_value,
npu_counters.npu_evt_counters[i].name,
npu_counters.npu_evt_counters[i].unit,
- &platform_counters);
+ counters);
}
for (i = 0; i < ETHOSU_DERIVED_NCOUNTERS; ++i) {
add_pmu_counter(
npu_counters.npu_derived_counters[i].counter_value,
npu_counters.npu_derived_counters[i].name,
npu_counters.npu_derived_counters[i].unit,
- &platform_counters);
+ counters);
}
add_pmu_counter(
npu_counters.npu_total_ccnt,
"NPU TOTAL",
- "cycles",
- &platform_counters);
+ unit_cycles,
+ counters);
#endif /* defined (ARM_NPU) */
#if defined(CPU_PROFILE_ENABLED)
@@ -111,14 +111,14 @@ pmu_counters platform_get_counters(void)
add_pmu_counter(
mps3_counters.counter_systick,
"CPU TOTAL",
- "cycles",
- &platform_counters);
+ unit_cycles,
+ counters);
add_pmu_counter(
get_tstamp_milliseconds(&mps3_counters),
"DURATION",
- "milliseconds",
- &platform_counters);
+ unit_ms,
+ counters);
#endif /* defined(CPU_PROFILE_ENABLED) */
#if !defined(CPU_PROFILE_ENABLED)
@@ -129,8 +129,6 @@ pmu_counters platform_get_counters(void)
UNUSED(i);
#endif /* !defined(ARM_NPU) */
#endif /* !defined(CPU_PROFILE_ENABLED) */
-
- return platform_counters;
}
uint32_t get_mps3_core_clock(void)
diff --git a/source/hal/source/platform/native/include/platform_drivers.h b/source/hal/source/platform/native/include/platform_drivers.h
index a203618..50164db 100644
--- a/source/hal/source/platform/native/include/platform_drivers.h
+++ b/source/hal/source/platform/native/include/platform_drivers.h
@@ -35,10 +35,9 @@ int platform_init(void);
void platform_release(void);
/**
- * @brief Sets the platform name.
- * @param[out] name Name of the platform to be set
- * @param[in] size Size of the input buffer
+ * @brief Gets the platform name.
+ * @return Pointer to the name
*/
-void platform_name(char* name, size_t size);
+const char* platform_name(void);
#endif /* PLATFORM_DRIVERS_H */
diff --git a/source/hal/source/platform/native/include/timer_native.h b/source/hal/source/platform/native/include/timer_native.h
index c8eeda2..da34b30 100644
--- a/source/hal/source/platform/native/include/timer_native.h
+++ b/source/hal/source/platform/native/include/timer_native.h
@@ -28,9 +28,9 @@
void platform_reset_counters(void);
/**
- * @brief Gets the current counter values.
- * @returns A populated instance of pmu_counters struct.
+ * @brief Gets the current counter values.
+ * @param[out] Pointer to a pmu_counters object.
**/
-pmu_counters platform_get_counters(void);
+void platform_get_counters(pmu_counters* counters);
#endif /* NATIVE_TIMER_H */
diff --git a/source/hal/source/platform/native/source/platform_drivers.c b/source/hal/source/platform/native/source/platform_drivers.c
index 10db99a..d5b3727 100644
--- a/source/hal/source/platform/native/source/platform_drivers.c
+++ b/source/hal/source/platform/native/source/platform_drivers.c
@@ -19,6 +19,8 @@
#include <string.h>
+static const char* s_platform_name = "native";
+
int platform_init(void)
{
return 0;
@@ -27,7 +29,7 @@ int platform_init(void)
void platform_release(void)
{}
-void platform_name(char* name, size_t size)
+const char* platform_name(void)
{
- strncpy(name, "native", size);
+ return s_platform_name;
} \ No newline at end of file
diff --git a/source/hal/source/platform/native/source/timer_native.c b/source/hal/source/platform/native/source/timer_native.c
index 590975f..7cd832c 100644
--- a/source/hal/source/platform/native/source/timer_native.c
+++ b/source/hal/source/platform/native/source/timer_native.c
@@ -32,25 +32,21 @@ extern "C" {
void platform_reset_counters() { /* Nothing to do */ }
-pmu_counters platform_get_counters(void)
+void platform_get_counters(pmu_counters* counters)
{
struct timespec current_time;
- pmu_counters platform_counters = {
- .num_counters = 0,
- .initialised = true
- };
+ counters->num_counters = 0;
+ counters->initialised = true;
clock_gettime(1, &current_time);
uint64_t microseconds = (current_time.tv_sec * MICROSECONDS_IN_SECOND) +
(current_time.tv_nsec / NANOSECONDS_IN_MICROSECOND);
#if NUM_PMU_COUNTERS > 0
- platform_counters.counters[0].value = microseconds;
- platform_counters.counters[0].name = "Duration";
- platform_counters.counters[0].unit = "microseconds";
- ++platform_counters.num_counters;
+ counters->counters[0].value = microseconds;
+ counters->counters[0].name = "Duration";
+ counters->counters[0].unit = "microseconds";
+ ++counters->num_counters;
#endif /* NUM_PMU_COUNTERS > 0 */
-
- return platform_counters;
}
#ifdef __cplusplus
diff --git a/source/hal/source/platform/simple/include/platform_drivers.h b/source/hal/source/platform/simple/include/platform_drivers.h
index 31bb682..7d075e7 100644
--- a/source/hal/source/platform/simple/include/platform_drivers.h
+++ b/source/hal/source/platform/simple/include/platform_drivers.h
@@ -39,10 +39,9 @@ int platform_init(void);
void platform_release(void);
/**
- * @brief Sets the platform name.
- * @param[out] name Name of the platform to be set
- * @param[in] size Size of the input buffer
+ * @brief Gets the platform name.
+ * @return Pointer to the name
*/
-void platform_name(char* name, size_t size);
+const char* platform_name(void);
#endif /* PLATFORM_DRIVERS_H */
diff --git a/source/hal/source/platform/simple/include/timer_simple_platform.h b/source/hal/source/platform/simple/include/timer_simple_platform.h
index 40acd03..20006cc 100644
--- a/source/hal/source/platform/simple/include/timer_simple_platform.h
+++ b/source/hal/source/platform/simple/include/timer_simple_platform.h
@@ -31,10 +31,10 @@
void platform_reset_counters(void);
/**
- * @brief Gets the current counter values.
- * @returns A populated instance of pmu_counters struct.
+ * @brief Gets the current counter values.
+ * @param[out] Pointer to a pmu_counters object.
**/
-pmu_counters platform_get_counters(void);
+void platform_get_counters(pmu_counters* counters);
/**
* @brief System tick interrupt handler.
diff --git a/source/hal/source/platform/simple/source/platform_drivers.c b/source/hal/source/platform/simple/source/platform_drivers.c
index 177ba70..3e04323 100644
--- a/source/hal/source/platform/simple/source/platform_drivers.c
+++ b/source/hal/source/platform/simple/source/platform_drivers.c
@@ -40,6 +40,9 @@
#endif /* ARM_NPU */
+/* Platform name */
+static const char* s_platform_name = DESIGN_NAME;
+
int platform_init(void)
{
SystemCoreClockUpdate(); /* From start up code */
@@ -72,7 +75,7 @@ int platform_init(void)
#endif /* ARM_NPU */
/* Print target design info */
- info("Target system design: %s\n", DESIGN_NAME);
+ info("Target system design: %s\n", s_platform_name);
return 0;
}
@@ -82,7 +85,7 @@ void platform_release(void)
__disable_irq();
}
-void platform_name(char* name, size_t size)
+const char* platform_name(void)
{
- strncpy(name, DESIGN_NAME, size);
+ return s_platform_name;
}
diff --git a/source/hal/source/platform/simple/source/timer_simple_platform.c b/source/hal/source/platform/simple/source/timer_simple_platform.c
index 94af308..3bb91d0 100644
--- a/source/hal/source/platform/simple/source/timer_simple_platform.c
+++ b/source/hal/source/platform/simple/source/timer_simple_platform.c
@@ -63,12 +63,10 @@ void platform_reset_counters(void)
debug("system tick config ready\n");
}
-pmu_counters platform_get_counters(void)
+void platform_get_counters(pmu_counters* counters)
{
- pmu_counters platform_counters = {
- .num_counters = 0,
- .initialised = true
- };
+ counters->num_counters = 0;
+ counters->initialised = true;
uint32_t i = 0;
#if defined (ARM_NPU)
@@ -78,20 +76,20 @@ pmu_counters platform_get_counters(void)
npu_counters.npu_evt_counters[i].counter_value,
npu_counters.npu_evt_counters[i].name,
npu_counters.npu_evt_counters[i].unit,
- &platform_counters);
+ counters);
}
for (i = 0; i < ETHOSU_DERIVED_NCOUNTERS; ++i) {
add_pmu_counter(
npu_counters.npu_derived_counters[i].counter_value,
npu_counters.npu_derived_counters[i].name,
npu_counters.npu_derived_counters[i].unit,
- &platform_counters);
+ counters);
}
add_pmu_counter(
npu_counters.npu_total_ccnt,
"NPU TOTAL",
"cycles",
- &platform_counters);
+ counters);
#endif /* defined (ARM_NPU) */
#if defined(CPU_PROFILE_ENABLED)
@@ -99,7 +97,7 @@ pmu_counters platform_get_counters(void)
Get_SysTick_Cycle_Count(),
"CPU TOTAL",
"cycles",
- &platform_counters);
+ counters);
#endif /* defined(CPU_PROFILE_ENABLED) */
#if !defined(CPU_PROFILE_ENABLED)
@@ -109,8 +107,6 @@ pmu_counters platform_get_counters(void)
UNUSED(i);
#endif /* !defined(ARM_NPU) */
#endif /* !defined(CPU_PROFILE_ENABLED) */
-
- return platform_counters;
}
void SysTick_Handler(void)
diff --git a/source/profiler/Profiler.cc b/source/profiler/Profiler.cc
index 7e10097..64edcf2 100644
--- a/source/profiler/Profiler.cc
+++ b/source/profiler/Profiler.cc
@@ -21,28 +21,27 @@
namespace arm {
namespace app {
- Profiler::Profiler(hal_platform* platform, const char* name = "Unknown")
- : m_name(name)
- {
- if (platform && platform->inited) {
- this->m_pPlatform = platform;
- this->Reset();
- } else {
- printf_err("Profiler %s initialised with invalid platform\n",
- this->m_name.c_str());
- }
- }
+ Profiler::Profiler()
+ : Profiler("Unknown")
+ {}
+
+ Profiler::Profiler(const char* name)
+ : m_name(name)
+ {}
bool Profiler::StartProfiling(const char* name)
{
if (name) {
this->SetName(name);
}
- if (this->m_pPlatform && !this->m_started) {
- this->m_pPlatform->timer->reset();
- this->m_tstampSt = this->m_pPlatform->timer->get_counters();
- this->m_started = true;
- return true;
+ if (!this->m_started) {
+ hal_pmu_reset();
+ this->m_tstampSt.initialised = false;
+ hal_pmu_get_counters(&this->m_tstampSt);
+ if (this->m_tstampSt.initialised) {
+ this->m_started = true;
+ return true;
+ }
}
printf_err("Failed to start profiler %s\n", this->m_name.c_str());
return false;
@@ -50,13 +49,17 @@ namespace app {
bool Profiler::StopProfiling()
{
- if (this->m_pPlatform && this->m_started) {
- this->m_tstampEnd = this->m_pPlatform->timer->get_counters();
+ if (this->m_started) {
+ this->m_tstampEnd.initialised = false;
+ hal_pmu_get_counters(&this->m_tstampEnd);
this->m_started = false;
-
- this->AddProfilingUnit(this->m_tstampSt, this->m_tstampEnd, this->m_name);
-
- return true;
+ if (this->m_tstampEnd.initialised) {
+ 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());
return false;
@@ -160,11 +163,6 @@ namespace app {
void Profiler::AddProfilingUnit(pmu_counters start, pmu_counters end,
const std::string& name)
{
- if (!this->m_pPlatform) {
- printf_err("Invalid platform\n");
- return;
- }
-
struct ProfilingUnit unit = {
.counters = end
};
diff --git a/source/profiler/include/Profiler.hpp b/source/profiler/include/Profiler.hpp
index b8f9089..581e1e5 100644
--- a/source/profiler/include/Profiler.hpp
+++ b/source/profiler/include/Profiler.hpp
@@ -62,13 +62,12 @@ namespace app {
public:
/**
* @brief Constructor for profiler.
- * @param[in] platform Pointer to a valid, initialised hal platform.
* @param[in] name A friendly name for this profiler.
**/
- Profiler(hal_platform* platform, const char* name);
+ Profiler(const char* name);
- /** Block the default constructor. */
- Profiler() = delete;
+ /** Default constructor. */
+ Profiler();
/** Default destructor. */
~Profiler() = default;
@@ -103,10 +102,7 @@ namespace app {
ProfilingMap m_series; /* Profiling series map. */
pmu_counters m_tstampSt{}; /* Container for a current starting timestamp. */
pmu_counters 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. */
-
std::string m_name; /* Name given to this profiler. */
/**
diff --git a/source/use_case/ad/src/MainLoop.cc b/source/use_case/ad/src/MainLoop.cc
index e858320..23d1e51 100644
--- a/source/use_case/ad/src/MainLoop.cc
+++ b/source/use_case/ad/src/MainLoop.cc
@@ -45,7 +45,7 @@ static void DisplayMenu()
}
-void main_loop(hal_platform& platform)
+void main_loop()
{
arm::app::AdModel model; /* Model wrapper object. */
@@ -59,9 +59,8 @@ void main_loop(hal_platform& platform)
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "ad"};
+ arm::app::Profiler profiler{"ad"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("clipIndex", 0);
caseContext.Set<int>("frameLength", g_FrameLength);
diff --git a/source/use_case/asr/src/MainLoop.cc b/source/use_case/asr/src/MainLoop.cc
index 058211a..51b0b18 100644
--- a/source/use_case/asr/src/MainLoop.cc
+++ b/source/use_case/asr/src/MainLoop.cc
@@ -65,7 +65,7 @@ static uint32_t GetOutputContextLen(const arm::app::Model& model,
static uint32_t GetOutputInnerLen(const arm::app::Model& model,
uint32_t outputCtxLen);
-void main_loop(hal_platform& platform)
+void main_loop()
{
arm::app::Wav2LetterModel model; /* Model wrapper object. */
@@ -99,9 +99,8 @@ void main_loop(hal_platform& platform)
GetLabelsVector(labels);
arm::app::AsrClassifier classifier; /* Classifier wrapper object. */
- arm::app::Profiler profiler{&platform, "asr"};
+ arm::app::Profiler profiler{"asr"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("clipIndex", 0);
caseContext.Set<uint32_t>("frameLength", g_FrameLength);
diff --git a/source/use_case/img_class/src/MainLoop.cc b/source/use_case/img_class/src/MainLoop.cc
index 7b67a19..d9fb925 100644
--- a/source/use_case/img_class/src/MainLoop.cc
+++ b/source/use_case/img_class/src/MainLoop.cc
@@ -25,7 +25,7 @@
using ImgClassClassifier = arm::app::Classifier;
-void main_loop(hal_platform& platform)
+void main_loop()
{
arm::app::MobileNetModel model; /* Model wrapper object. */
@@ -38,9 +38,8 @@ void main_loop(hal_platform& platform)
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "img_class"};
+ arm::app::Profiler profiler{"img_class"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
diff --git a/source/use_case/inference_runner/src/MainLoop.cc b/source/use_case/inference_runner/src/MainLoop.cc
index cfdc520..ddff40c 100644
--- a/source/use_case/inference_runner/src/MainLoop.cc
+++ b/source/use_case/inference_runner/src/MainLoop.cc
@@ -26,7 +26,7 @@ enum opcodes
MENU_OPT_SHOW_MODEL_INFO, /* Show model info. */
};
-void main_loop(hal_platform& platform)
+void main_loop()
{
arm::app::TestModel model; /* Model wrapper object. */
@@ -39,10 +39,8 @@ void main_loop(hal_platform& platform)
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "inference_runner"};
+ arm::app::Profiler profiler{"inference_runner"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
diff --git a/source/use_case/kws/src/MainLoop.cc b/source/use_case/kws/src/MainLoop.cc
index 76dff8c..e590c4a 100644
--- a/source/use_case/kws/src/MainLoop.cc
+++ b/source/use_case/kws/src/MainLoop.cc
@@ -48,7 +48,7 @@ static void DisplayMenu()
fflush(stdout);
}
-void main_loop(hal_platform& platform)
+void main_loop()
{
arm::app::MicroNetKwsModel model; /* Model wrapper object. */
@@ -61,10 +61,8 @@ void main_loop(hal_platform& platform)
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "kws"};
+ arm::app::Profiler profiler{"kws"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("clipIndex", 0);
caseContext.Set<int>("frameLength", g_FrameLength);
diff --git a/source/use_case/kws_asr/src/MainLoop.cc b/source/use_case/kws_asr/src/MainLoop.cc
index 096c966..5c1d0e0 100644
--- a/source/use_case/kws_asr/src/MainLoop.cc
+++ b/source/use_case/kws_asr/src/MainLoop.cc
@@ -67,7 +67,7 @@ static uint32_t GetOutputContextLen(const arm::app::Model& model,
static uint32_t GetOutputInnerLen(const arm::app::Model& model,
uint32_t outputCtxLen);
-void main_loop(hal_platform& platform)
+void main_loop()
{
/* Model wrapper objects. */
arm::app::MicroNetKwsModel kwsModel;
@@ -104,10 +104,8 @@ void main_loop(hal_platform& platform)
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "kws_asr"};
+ arm::app::Profiler profiler{"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);
caseContext.Set<uint32_t>("clipIndex", 0);
diff --git a/source/use_case/noise_reduction/src/MainLoop.cc b/source/use_case/noise_reduction/src/MainLoop.cc
index bcaff6d..5fd7823 100644
--- a/source/use_case/noise_reduction/src/MainLoop.cc
+++ b/source/use_case/noise_reduction/src/MainLoop.cc
@@ -56,7 +56,7 @@ static bool SetAppCtxClipIdx(arm::app::ApplicationContext& ctx, uint32_t idx)
return true;
}
-void main_loop(hal_platform& platform)
+void main_loop()
{
arm::app::RNNoiseModel model; /* Model wrapper object. */
@@ -71,10 +71,8 @@ void main_loop(hal_platform& platform)
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "noise_reduction"};
+ arm::app::Profiler profiler{"noise_reduction"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
-
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<uint32_t>("numInputFeatures", g_NumInputFeatures);
caseContext.Set<uint32_t>("frameLength", g_FrameLength);
caseContext.Set<uint32_t>("frameStride", g_FrameStride);
diff --git a/source/use_case/object_detection/src/MainLoop.cc b/source/use_case/object_detection/src/MainLoop.cc
index 0f98c8a..acfc195 100644
--- a/source/use_case/object_detection/src/MainLoop.cc
+++ b/source/use_case/object_detection/src/MainLoop.cc
@@ -36,7 +36,7 @@ static void DisplayDetectionMenu()
fflush(stdout);
}
-void main_loop(hal_platform& platform)
+void main_loop()
{
arm::app::YoloFastestModel model; /* Model wrapper object. */
@@ -49,9 +49,8 @@ void main_loop(hal_platform& platform)
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "object_detection"};
+ arm::app::Profiler profiler{"object_detection"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
arm::app::object_detection::DetectorPostprocessing postp;
diff --git a/source/use_case/vww/src/MainLoop.cc b/source/use_case/vww/src/MainLoop.cc
index 03d6196..041ea18 100644
--- a/source/use_case/vww/src/MainLoop.cc
+++ b/source/use_case/vww/src/MainLoop.cc
@@ -25,7 +25,7 @@
using ViusalWakeWordClassifier = arm::app::Classifier;
-void main_loop(hal_platform &platform)
+void main_loop()
{
arm::app::VisualWakeWordModel model; /* Model wrapper object. */
@@ -38,9 +38,8 @@ void main_loop(hal_platform &platform)
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "vww"};
+ arm::app::Profiler profiler{"vww"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
diff --git a/tests/common/ProfilerTests.cc b/tests/common/ProfilerTests.cc
index 889e2f2..91ac973 100644
--- a/tests/common/ProfilerTests.cc
+++ b/tests/common/ProfilerTests.cc
@@ -25,22 +25,16 @@
TEST_CASE("Common: Test Profiler")
{
- hal_platform platform;
- platform_timer timer {};
+ hal_platform_init();
- /* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
-
- /* An invalid profiler shouldn't be of much use */
- SECTION("Test invalid profiler") {
- arm::app::Profiler profilerInvalid{nullptr, "test_invalid"};
- REQUIRE(false == profilerInvalid.StartProfiling());
- REQUIRE(false == profilerInvalid.StopProfiling());
+ SECTION("Test default construction") {
+ arm::app::Profiler profiler{};
+ REQUIRE(true == profiler.StartProfiling());
+ REQUIRE(true == profiler.StopProfiling());
}
SECTION("Test valid profiler") {
- arm::app::Profiler profilerValid{&platform, "test_valid"};
+ arm::app::Profiler profilerValid{"test_valid"};
REQUIRE(true == profilerValid.StartProfiling());
REQUIRE(true == profilerValid.StopProfiling());
std::vector<arm::app::ProfileResult> results;
@@ -57,7 +51,7 @@ TEST_CASE("Common: Test Profiler")
}
SECTION("Test multiple profilers") {
- arm::app::Profiler profilerValid{&platform, "one"};
+ arm::app::Profiler profilerValid{"one"};
REQUIRE(true == profilerValid.StartProfiling());
REQUIRE(true == profilerValid.StopProfiling());
@@ -78,7 +72,7 @@ TEST_CASE("Common: Test Profiler")
#if defined (CPU_PROFILE_ENABLED)
SECTION("Test CPU profiler") {
- arm::app::Profiler profilerCPU{&platform, "test cpu"};
+ arm::app::Profiler profilerCPU{"test cpu"};
std::vector<arm::app::ProfileResult> results;
profilerCPU.StartProfiling();
profilerCPU.StopProfiling();
diff --git a/tests/use_case/img_class/ImgClassificationUCTest.cc b/tests/use_case/img_class/ImgClassificationUCTest.cc
index 62d8eb8..b9caf61 100644
--- a/tests/use_case/img_class/ImgClassificationUCTest.cc
+++ b/tests/use_case/img_class/ImgClassificationUCTest.cc
@@ -43,12 +43,8 @@ TEST_CASE("Model info")
TEST_CASE("Inference by index", "[.]")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
/* Model wrapper object. */
arm::app::MobileNetModel model;
@@ -59,9 +55,8 @@ TEST_CASE("Inference by index", "[.]")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "img_class"};
+ arm::app::Profiler profiler{"img_class"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
arm::app::Classifier classifier; /* Classifier wrapper object. */
@@ -81,12 +76,8 @@ TEST_CASE("Inference by index", "[.]")
TEST_CASE("Inference run all images", "[.]")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
/* Model wrapper object. */
arm::app::MobileNetModel model;
@@ -97,9 +88,8 @@ TEST_CASE("Inference run all images", "[.]")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "img_class"};
+ arm::app::Profiler profiler{"img_class"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
arm::app::Classifier classifier; /* classifier wrapper object. */
@@ -115,12 +105,8 @@ TEST_CASE("Inference run all images", "[.]")
TEST_CASE("List all images")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
/* Model wrapper object. */
arm::app::MobileNetModel model;
@@ -130,8 +116,6 @@ TEST_CASE("List all images")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
-
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
REQUIRE(arm::app::ListFilesHandler(caseContext));
diff --git a/tests/use_case/kws/KWSHandlerTest.cc b/tests/use_case/kws/KWSHandlerTest.cc
index 3013611..d0a8a3f 100644
--- a/tests/use_case/kws/KWSHandlerTest.cc
+++ b/tests/use_case/kws/KWSHandlerTest.cc
@@ -43,12 +43,8 @@ TEST_CASE("Model info")
TEST_CASE("Inference by index")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
/* Model wrapper object. */
arm::app::MicroNetKwsModel model;
@@ -59,9 +55,8 @@ TEST_CASE("Inference by index")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "kws"};
+ arm::app::Profiler profiler{"kws"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<int>("frameLength", g_FrameLength); /* 640 sample length for MicroNetKws. */
caseContext.Set<int>("frameStride", g_FrameStride); /* 320 sample stride for MicroNetKws. */
@@ -120,12 +115,8 @@ TEST_CASE("Inference by index")
TEST_CASE("Inference run all clips")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
/* Model wrapper object. */
arm::app::MicroNetKwsModel model;
@@ -136,9 +127,8 @@ TEST_CASE("Inference run all clips")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "kws"};
+ arm::app::Profiler profiler{"kws"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("clipIndex", 0);
caseContext.Set<int>("frameLength", g_FrameLength); /* 640 sample length for MicroNet. */
@@ -156,12 +146,8 @@ TEST_CASE("Inference run all clips")
TEST_CASE("List all audio clips")
{
- hal_platform platform;
- platform_timer timer;
-
- /* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ /* Initialise the HAL and platform. */
+ hal_platform_init();
/* Model wrapper object. */
arm::app::MicroNetKwsModel model;
@@ -172,7 +158,6 @@ TEST_CASE("List all audio clips")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
REQUIRE(arm::app::ListFilesHandler(caseContext));
diff --git a/tests/use_case/noise_reduction/RNNNoiseUCTests.cc b/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
index a376dd5..cc1b4d7 100644
--- a/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
+++ b/tests/use_case/noise_reduction/RNNNoiseUCTests.cc
@@ -24,17 +24,12 @@
#include <hal.h>
#include <Profiler.hpp>
-#define PLATFORM \
-hal_platform platform; \
-platform_timer timer; \
-hal_init(&platform, &timer); \
-hal_platform_init(&platform);
+#define PLATFORM hal_platform_init();
#define CONTEXT \
arm::app::ApplicationContext caseContext; \
-arm::app::Profiler profiler{&platform, "noise_reduction"}; \
+arm::app::Profiler profiler{"noise_reduction"}; \
caseContext.Set<arm::app::Profiler&>("profiler", profiler); \
-caseContext.Set<hal_platform&>("platform", platform); \
caseContext.Set<arm::app::RNNoiseModel&>("model", model);
TEST_CASE("Verify output tensor memory dump")
diff --git a/tests/use_case/object_detection/ObjectDetectionUCTest.cc b/tests/use_case/object_detection/ObjectDetectionUCTest.cc
index 79e76bd..a7e4f33 100644
--- a/tests/use_case/object_detection/ObjectDetectionUCTest.cc
+++ b/tests/use_case/object_detection/ObjectDetectionUCTest.cc
@@ -42,12 +42,8 @@ TEST_CASE("Model info")
TEST_CASE("Inference by index")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
/* Model wrapper object. */
arm::app::YoloFastestModel model;
@@ -58,9 +54,8 @@ TEST_CASE("Inference by index")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "object_detection"};
+ arm::app::Profiler profiler{"object_detection"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
arm::app::object_detection::DetectorPostprocessing postp;
@@ -72,12 +67,8 @@ TEST_CASE("Inference by index")
TEST_CASE("Inference run all images")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
/* Model wrapper object. */
arm::app::YoloFastestModel model;
@@ -88,9 +79,8 @@ TEST_CASE("Inference run all images")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "object_detection"};
+ arm::app::Profiler profiler{"object_detection"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
arm::app::object_detection::DetectorPostprocessing postp;
@@ -102,12 +92,8 @@ TEST_CASE("Inference run all images")
TEST_CASE("List all images")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform. */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
/* Model wrapper object. */
arm::app::YoloFastestModel model;
@@ -117,8 +103,6 @@ TEST_CASE("List all images")
/* Instantiate application context. */
arm::app::ApplicationContext caseContext;
-
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
REQUIRE(arm::app::ListFilesHandler(caseContext));
diff --git a/tests/use_case/vww/VisualWakeWordUCTests.cc b/tests/use_case/vww/VisualWakeWordUCTests.cc
index 16bd5a6..531764b 100644
--- a/tests/use_case/vww/VisualWakeWordUCTests.cc
+++ b/tests/use_case/vww/VisualWakeWordUCTests.cc
@@ -41,12 +41,7 @@ TEST_CASE("Model info")
TEST_CASE("Inference by index")
{
- hal_platform platform;
- platform_timer timer;
-
- /* Initialise the HAL and platform */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
arm::app::VisualWakeWordModel model; /* model wrapper object */
@@ -55,9 +50,8 @@ TEST_CASE("Inference by index")
/* Instantiate application context */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "pd"};
+ arm::app::Profiler profiler{"pd"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
arm::app::Classifier classifier; /* classifier wrapper object */
@@ -76,12 +70,8 @@ TEST_CASE("Inference by index")
TEST_CASE("Inference run all images")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
arm::app::VisualWakeWordModel model; /* model wrapper object */
@@ -90,9 +80,8 @@ TEST_CASE("Inference run all images")
/* Instantiate application context */
arm::app::ApplicationContext caseContext;
- arm::app::Profiler profiler{&platform, "pd"};
+ arm::app::Profiler profiler{"pd"};
caseContext.Set<arm::app::Profiler&>("profiler", profiler);
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
caseContext.Set<uint32_t>("imgIndex", 0);
arm::app::Classifier classifier; /* classifier wrapper object */
@@ -107,12 +96,8 @@ TEST_CASE("Inference run all images")
TEST_CASE("List all images")
{
- hal_platform platform;
- platform_timer timer;
-
/* Initialise the HAL and platform */
- hal_init(&platform, &timer);
- hal_platform_init(&platform);
+ hal_platform_init();
arm::app::VisualWakeWordModel model; /* model wrapper object */
@@ -122,7 +107,6 @@ TEST_CASE("List all images")
/* Instantiate application context */
arm::app::ApplicationContext caseContext;
- caseContext.Set<hal_platform&>("platform", platform);
caseContext.Set<arm::app::Model&>("model", model);
REQUIRE(arm::app::ListFilesHandler(caseContext));