Skip to content
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

Tensor Arena size reported by Recording Memory APIs is insufficient during Invoke() #2738

Open
joshih-cad opened this issue Oct 29, 2024 · 0 comments

Comments

@joshih-cad
Copy link

joshih-cad commented Oct 29, 2024

We have followed the steps mentioned in tensorflow/lite/micro/docs/memory_management.md to identify tensor arena for a given network and then allocated the reported memory to run model inference.

However, after Invoke(), we run into allocation issues in network level Prepare() / tensor allocation functions.
We suspect that the Recording Memory APIs do not consider the memory needed by temporary_buffer allocations in the Prepare() stage.
The total arena size reported = Head(Scratch) + Tail (Persist) which is required by the network during Eval() stage.
But the actual memory size needed is greater than what’s reported. We also think that Tail memory (Persist) is allocated first
and then the remaining memory may/may-not be sufficient for Head + Temp allocations depending on the model.

We have a sample model for which we run into arena size related errors. Sharing details below:

  1. For the sample model, the arena size reported was:
    img0
  2. On allocating and running with 960 bytes arena, we see the following error:
    img1
  3. Repo details: commit e440f0a (HEAD -> main, origin/main, origin/HEAD)
  4. Tools/target used: gcc compiler on x86 target.
  5. Steps to reproduce:
    a. Extract sample_model.zip attached and copy the sample_model folder in tensorflow/lite/micro/examples/
    b. >> make -f tensorflow/lite/micro/tools/make/Makefile test_sample_model_test
    c. In order to print the arena size report details, un-comment line 28 in sample_model/sample_model_test.cc

CC: @suleshahid @pyu10055 @TFLM-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant