You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/04/03 02:25:05 UTC

[GitHub] [tvm] guberti opened a new pull request #10886: Fix Arduino workspace alignment

guberti opened a new pull request #10886:
URL: https://github.com/apache/tvm/pull/10886


   The `StackMemoryManager` in the `crt` currently requires `g_aot_memory` (the AOT memory array) to be 16 byte aligned. If `g_aot_memory` is **not** 16 byte aligned, then `StackMemoryManager_Init` decreases `workspace_size` (the amount of memory we use) to resolve the issue:
   https://github.com/apache/tvm/blob/2b94a7e6b19d4bba0d5e17fc5190e3da701e31db/src/runtime/crt/memory/stack_allocator.c#L89-L91
   
   However, when the size of our AOT memory array (`WORKSPACE_SIZE`) is set, it is drawn from the MLF file to be the smallest possible value. This means that whenever `g_aot_memory` is not 16 byte aligned, the `StackMemoryManager` will decrease its size, which will cause inference to fail.
   
   This occurs in the Arduino backend, and this PR adds code to force `g_aot_memory` to be 16 byte aligned (thus making sure `offset = 0` and solving the issue for Arduino). However, I believe this bug also effects Zephyr and Ethos. @mehrdadh added the following code to circumvent the issue for Zephyr, but I believe Ethos is vulnerable (I don't have a board, so I can't test myself)
   
   https://github.com/apache/tvm/blob/2f937801de21757a409d9d193f43fe5c0ab5a202/tests/micro/zephyr/test_utils.py#L88-L98
   
   I'll make a follow-up PR to fix the issue more nicely for Zephyr and Ethos (and possibly other `crt` users), and to add a unit test. However, for now I'd love to get this merged ASAP so Arduino can avoid this cryptic bug. I've attached both an Arduino sketch (as a `.zip`) where this bug occurs - to see it happen, compile it and upload it to a Nano 33 BLE. Note that the issue might not happen on other boards/platforms where the bug exists, as if `g_aot_memory` is already 16 byte aligned, inference will work despite the bug.
   [project.zip](https://github.com/apache/tvm/files/8403683/project.zip)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org