-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CMSIS-NN] Fix memory alignment bug in CMSIS-NN demo #11221
Conversation
@grant-arm Thanks for the PR. Just for my understanding, why do we need to align .rodata to 16 bytes? I have seen this for constants in the code generated C files as well. Also, does it hold good for all variations of Arm® Cortex®-M processors? |
Hi @ashutosh-arm, the reason is because we default the workspace allocation alignment to 16 bytes in a few places, for example: tvm/src/relay/backend/aot_executor_codegen.cc Lines 831 to 832 in eae836c
Which means we have to ensure we start on a 16 byte boundary to avoid overflows when we round up the allocations in memory planning. I believe we chose this because it's the max alignment required across all devices (including microNPUs), we could actually detect this and align as per the architecture at some point but the savings are minimal. |
Thanks for the detailed explanation @Mousius. |
* Updates convert_image.py to include memory alignment Change-Id: I41c9a1f86a73450d64fb196a27994929ad16366f
7971d0d
to
8bc9fe3
Compare
* Updates convert_image.py to include memory alignment
* Updates convert_image.py to include memory alignment
* Updates convert_image.py to include memory alignment
* Updates convert_image.py to include memory alignment
There is a latent bug in the CMSIS-NN demo app where the input and output tensors generated by the
create_image.py
script are not 16-byte aligned in memory. Although this does not cause an issue in the demo using the currentperson_detect
model, if a different model is substituted with a larger output tensor, it causes the FVP to hang in certain cases.This PR updates
create_image.py
to correct the issue.@Mousius @ashutosh-arm @areusch