diff --git a/3rdparty/mlperftiny/README.md b/3rdparty/mlperftiny/README.md index 7707f7e58b7f6..28938e90d7442 100644 --- a/3rdparty/mlperftiny/README.md +++ b/3rdparty/mlperftiny/README.md @@ -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). diff --git a/apps/microtvm/zephyr/template_project/src/mlperftiny/README.md b/apps/microtvm/zephyr/template_project/src/mlperftiny/README.md new file mode 100644 index 0000000000000..2b41c1cb6a6a7 --- /dev/null +++ b/apps/microtvm/zephyr/template_project/src/mlperftiny/README.md @@ -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. diff --git a/apps/microtvm/zephyr/template_project/src/mlperftiny/main.cc b/apps/microtvm/zephyr/template_project/src/mlperftiny/main.cc index 16d2de8fd715b..4c91177062ad5 100644 --- a/apps/microtvm/zephyr/template_project/src/mlperftiny/main.cc +++ b/apps/microtvm/zephyr/template_project/src/mlperftiny/main.cc @@ -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 diff --git a/apps/microtvm/zephyr/template_project/src/mlperftiny/submitter_implemented.cc b/apps/microtvm/zephyr/template_project/src/mlperftiny/submitter_implemented.cc index 86373425f4bfe..84baee3072cde 100644 --- a/apps/microtvm/zephyr/template_project/src/mlperftiny/submitter_implemented.cc +++ b/apps/microtvm/zephyr/template_project/src/mlperftiny/submitter_implemented.cc @@ -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(ee_get_buffer_pointer()); #elif TARGET_MODEL == 2 // VWW + // Converting uint8 to int8 int8_t* temp_int = reinterpret_cast(ee_get_buffer_pointer()); for (size_t i = 0; i < MAX_DB_INPUT_SIZE; i++) { temp_int[i] -= 128; @@ -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() {} @@ -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; @@ -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); @@ -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 */ @@ -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