Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mehrdadh committed Jan 5, 2023
1 parent dcfb469 commit 13abc4e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/mlperftiny/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# MLPerf™ Tiny Benchmark API
This directory includes API files to build a microTVM project that could be tested with EEMBC benchmark runner. API files are captured from [MLCommons/tiny repository](https://github.com/mlcommons/tiny).
This directory includes API files to build a microTVM project that could be tested with EEMBC benchmark runner. API files are captured from the [MLCommons/tiny repository](https://github.com/mlcommons/tiny).
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# MLPerf Tiny Project API
This directory includes source files to build a Zephyr microTVM project to use for benchmarking with EEMBC runner. This project has been tested with NUCLEO_L4R5ZI and NRF5340DK.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
int main(int argc, char* argv[]) {
#if NRF_BOARD == 1
// Set frequency to 128MHz for nrf5340dk_nrf534 by setting the clock divider to 0.
// 0x50005558 is the clock division reg address.
uint32_t* clock_div = (uint32_t*)0x50005558;
*clock_div = 0;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ static const gpio_pin_t g_gpio_pin = 6;
#endif

// Implement this method to prepare for inference and preprocess inputs.
// Modified from source
void th_load_tensor() {
#if TARGET_MODEL == 1 // KWS
g_input_data = static_cast<void*>(ee_get_buffer_pointer());
#elif TARGET_MODEL == 2 // VWW
// Converting uint8 to int8
int8_t* temp_int = reinterpret_cast<int8_t*>(ee_get_buffer_pointer());
for (size_t i = 0; i < MAX_DB_INPUT_SIZE; i++) {
temp_int[i] -= 128;
Expand Down Expand Up @@ -111,9 +113,11 @@ void th_results() {
}

// Implement this method with the logic to perform one inference cycle.
// Modified from source
void th_infer() { TVMInfer(g_input_data); }

/// \brief optional API.
// Modified from source
void th_final_initialize(void) { TVMRuntimeInit(); }

void th_pre() {}
Expand Down Expand Up @@ -143,6 +147,8 @@ void* th_memcpy(void* dst, const void* src, size_t n) { return memcpy(dst, src,

/* N.B.: Many embedded *printf SDKs do not support all format specifiers. */
int th_vprintf(const char* format, va_list ap) { return vprintf(format, ap); }

// Modified from source
void th_printf(const char* p_fmt, ...) {
char buffer[128];
int size;
Expand All @@ -153,8 +159,10 @@ void th_printf(const char* p_fmt, ...) {
TVMPlatformWriteSerial(buffer, (size_t)size);
}

// Modified from source
char th_getchar() { return TVMPlatformUartRxRead(); }

// Modified from source
void th_serialport_initialize(void) {
#if EE_CFG_ENERGY_MODE == 1 && NRF_BOARD != 1
TVMPlatformUARTInit(9600);
Expand All @@ -163,6 +171,7 @@ void th_serialport_initialize(void) {
#endif
}

// Modified from source
void th_timestamp(void) {
#if EE_CFG_ENERGY_MODE == 1 && NRF_BOARD != 1
/* USER CODE 1 BEGIN */
Expand All @@ -182,6 +191,7 @@ void th_timestamp(void) {
#endif
}

// Modified from source
void th_timestamp_initialize(void) {
/* USER CODE 1 BEGIN */
// Setting up BOTH perf and energy here
Expand Down
3 changes: 2 additions & 1 deletion cmake/modules/Zephyr.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ if(USE_MICRO)
"apps/microtvm/zephyr/template_project/src/aot_standalone_demo *.h -> zephyr/src/aot_standalone_demo"
"apps/microtvm/zephyr/template_project/src/host_driven *.c -> zephyr/src/host_driven"
"apps/microtvm/zephyr/template_project/src/host_driven *.h -> zephyr/src/host_driven"
"apps/microtvm/zephyr/template_project/src/mlperftiny * -> zephyr/src/mlperftiny"
"apps/microtvm/zephyr/template_project/src/mlperftiny *.cc -> zephyr/src/mlperftiny"
"apps/microtvm/zephyr/template_project/src/mlperftiny *.h -> zephyr/src/mlperftiny"
"3rdparty/mlperftiny/api * -> zephyr/src/mlperftiny/api"
"apps/microtvm/zephyr/template_project/fvp-hack * -> zephyr/fvp-hack"
"apps/microtvm/zephyr/template_project/qemu-hack * -> zephyr/qemu-hack"
Expand Down

0 comments on commit 13abc4e

Please sign in to comment.