You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by le...@apache.org on 2022/03/08 15:34:12 UTC

[tvm] branch main updated: [microNPU] modify the demo to use USMP (#10511)

This is an automated email from the ASF dual-hosted git repository.

leandron pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new acf8be7  [microNPU] modify the demo to use USMP (#10511)
acf8be7 is described below

commit acf8be70f738d2bae0ca30ade1ea11af0f9c790f
Author: Manupa Karunaratne <ma...@arm.com>
AuthorDate: Tue Mar 8 15:33:32 2022 +0000

    [microNPU] modify the demo to use USMP (#10511)
    
    * [microNPU] modify the demo to use USMP
    
    This commit changes the demo to use USMP.
    
    Change-Id: I87e85fdd9b2efea9559dda186c1644e4d63509ff
    
    * [microNPU] modify the demo to use USMP
    
    * removing a repeated TVMC CLI argument
    
    Change-Id: I3e1ec328155bfc4c9ce813224a7f06b09e66232c
---
 apps/microtvm/ethosu/corstone300.ld        | 16 +++++++++-------
 apps/microtvm/ethosu/include/tvm_runtime.h |  9 ++-------
 apps/microtvm/ethosu/run_demo.sh           |  3 +++
 apps/microtvm/ethosu/src/demo_bare_metal.c |  3 ---
 apps/microtvm/ethosu/src/demo_freertos.c   |  2 --
 5 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/apps/microtvm/ethosu/corstone300.ld b/apps/microtvm/ethosu/corstone300.ld
index ddf55b8..3f36f21 100644
--- a/apps/microtvm/ethosu/corstone300.ld
+++ b/apps/microtvm/ethosu/corstone300.ld
@@ -207,6 +207,15 @@ SECTIONS
    */
   __etext = ALIGN (4);
 
+  .sram :
+  {
+    . = ALIGN(16);
+    *(.bss.ethosu_fast_memory);
+    . = ALIGN(16);
+    *(.data.tvm);
+    . = ALIGN(16);
+  } > SRAM AT > SRAM
+
   .data : AT (__etext)
   {
     __data_start__ = .;
@@ -242,13 +251,6 @@ SECTIONS
 
   } > DTCM
 
-  .sram :
-  {
-    . = ALIGN(16);
-    *(.bss.ethosu_fast_memory);
-    . = ALIGN(16);
-  } > SRAM AT > SRAM
-
   .bss.NoInit :
   {
     . = ALIGN(16);
diff --git a/apps/microtvm/ethosu/include/tvm_runtime.h b/apps/microtvm/ethosu/include/tvm_runtime.h
index 3ab9981..2b59d93 100644
--- a/apps/microtvm/ethosu/include/tvm_runtime.h
+++ b/apps/microtvm/ethosu/include/tvm_runtime.h
@@ -27,11 +27,6 @@
 extern "C" {
 #endif
 
-#define WORKSPACE_SIZE (16384 * 1024)
-__attribute__((section("ethosu_scratch"))) static uint8_t g_aot_memory[WORKSPACE_SIZE];
-
-tvm_workspace_t app_workspace;
-
 void __attribute__((noreturn)) TVMPlatformAbort(tvm_crt_error_t error_code) {
   printf("TVMPlatformAbort: %d\n", error_code);
   printf("EXITTHESIM\n");
@@ -39,11 +34,11 @@ void __attribute__((noreturn)) TVMPlatformAbort(tvm_crt_error_t error_code) {
 }
 
 tvm_crt_error_t TVMPlatformMemoryAllocate(size_t num_bytes, DLDevice dev, void** out_ptr) {
-  return StackMemoryManager_Allocate(&app_workspace, num_bytes, out_ptr);
+  return kTvmErrorFunctionCallNotImplemented;
 }
 
 tvm_crt_error_t TVMPlatformMemoryFree(void* ptr, DLDevice dev) {
-  return StackMemoryManager_Free(&app_workspace, ptr);
+  return kTvmErrorFunctionCallNotImplemented;
 }
 
 void TVMLogf(const char* msg, ...) {
diff --git a/apps/microtvm/ethosu/run_demo.sh b/apps/microtvm/ethosu/run_demo.sh
index 18d82f7..5f8807c 100755
--- a/apps/microtvm/ethosu/run_demo.sh
+++ b/apps/microtvm/ethosu/run_demo.sh
@@ -151,6 +151,9 @@ python3 -m tvm.driver.tvmc compile --target=ethos-u,cmsis-nn,c \
     --executor=aot \
     --executor-aot-interface-api=c \
     --executor-aot-unpacked-api=1 \
+    --pass-config tir.usmp.enable=1 \
+    --pass-config tir.usmp.algorithm=hill_climb \
+    --pass-config tir.disable_storage_rewrite=1 \
     --pass-config tir.disable_vectorize=1 ./mobilenet_v2_1.0_224_INT8.tflite --output-format=mlf
 tar -xf module.tar
 
diff --git a/apps/microtvm/ethosu/src/demo_bare_metal.c b/apps/microtvm/ethosu/src/demo_bare_metal.c
index 78d79dc..febc212 100644
--- a/apps/microtvm/ethosu/src/demo_bare_metal.c
+++ b/apps/microtvm/ethosu/src/demo_bare_metal.c
@@ -35,9 +35,6 @@ int main(int argc, char** argv) {
   printf("Starting Demo\n");
   EthosuInit();
 
-  printf("Allocating memory\n");
-  StackMemoryManager_Init(&app_workspace, g_aot_memory, WORKSPACE_SIZE);
-
   printf("Running inference\n");
   struct tvmgen_default_outputs outputs = {
       .MobilenetV2_Predictions_Reshape_11 = output,
diff --git a/apps/microtvm/ethosu/src/demo_freertos.c b/apps/microtvm/ethosu/src/demo_freertos.c
index 2be8f11..4fa363a 100644
--- a/apps/microtvm/ethosu/src/demo_freertos.c
+++ b/apps/microtvm/ethosu/src/demo_freertos.c
@@ -49,8 +49,6 @@ int main(void) {
   uart_init();
   // NPU
   EthosuInit();
-  // TVM Memory Manager
-  StackMemoryManager_Init(&app_workspace, g_aot_memory, WORKSPACE_SIZE);
 
   // Queue for inferences
   xQueue = xQueueCreate(mainQUEUE_LENGTH, sizeof(uint8_t*));