mlearning/tflite-micro: make the tflm tool run real models - #3804
Open
Abhishekmishra2808 wants to merge 1 commit into
Open
Abhishekmishra2808 wants to merge 1 commit into
Abhishekmishra2808 wants to merge 1 commit into
Conversation
The tflm tool could only allocate a model: it knew nine operators, ran Invoke() on uninitialized input, and never printed the result. The 64 KB MicroProfiler also lived on the 4 KB task stack. Register the operators a model uses (about 90 builtins), verify the file with the FlatBuffers verifier, and add: -I print operators, input/output tensors and arena usage -d comma separated input values, quantized automatically -x raw input tensor file -n repeat inference and print the average Invoke() time Outputs are printed dequantized with argmax. Inputs are restored before every run because the planner may reuse their buffers. The resolver, profiler and interpreter are allocated on the heap. Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
tflmtool could only allocate a model: it knew nine operators, ranInvoke()on uninitialized input and never printed the result. The 64 KBMicroProfileralso lived on the 4 KB task stack.This PR registers the operators a model uses (about 90 builtins), verifies the file with the FlatBuffers verifier, and adds:
-Iprint operators, input/output tensors and arena usage-dcomma separated input values, quantized automatically-xraw input tensor file-nrepeat inference and print the averageInvoke()timeOutputs are printed dequantized, with argmax. Inputs are restored before every run because the memory planner may reuse their buffers. The resolver, profiler and interpreter are allocated on the heap.
Impact
tflmcan now inspect and run.tflitemodels from NSH onsim:tflm, no board needed.-i,-a,-E,-C,-o,-p) are unchanged. Onlytflm_tool.ccchanges; no Kconfig or build changes.Testing
Host: Ubuntu 24.04 (WSL2) x86_64, gcc 13.3.0. Target:
sim:tflm(Makefile build, no warnings). Models are from the downloaded TFLM tree, shared through hostfs.-d 1.5708(pi/2) gives1.003206, the sine of the input. The 20 micro_speech runs give the same output as a single run. The last command reports an unsupported custom operator by name.