tensorflow / tflite-micro

Infrastructure to enable deployment of ML models to low-power resource-constrained embedded targets (including microcontrollers and digital signal processors).
Apache License 2.0
1.86k stars 807 forks source link

Add an arena_allocation_bytes() to micro_interpreter to denote the total amount of tensor arena to be allocated #1104

Closed panickal-xmos closed 1 year ago

panickal-xmos commented 2 years ago

arena_used_bytes() is currently provided by micro_interpreter. This can be called after AllocateTensors() has completed and gives the amount of bytes currently being used in the arena.

However, this does not help to know the total amount of tensor arena needed for (doing temporary allocations, running the memory planner, etc.) a particular model.

An arena_allocation_bytes() provided by micro_interpreter would be very useful to know the exact amount of tensor arena memory to be allocated for running a particular model. The simple memory allocator would keep track of the maximum memory needed.

I have a patch locally that implements this feature. Is this feature of interest?

github-actions[bot] commented 1 year ago

"This issue is being marked as stale due to inactivity. Remove label or comment to prevent closure in 5 days."

github-actions[bot] commented 1 year ago

"This issue is being closed because it has been marked as stale for 5 days with no further activity."

mansnils commented 1 year ago

Hi @panickal-xmos - I just came across this issue and it sounds interesting. So you would be able to call this before AllocateTensors()? If you still have the patch please consider sharing it.