Description
A sum of python and C++ scripts to attach for embedded solutions on TFLite to analyze dynamic and avoid memory allocations, as decribed in this figure.
Requirements
- newlib (modified and compiled with extra hook options) !update link to fork/downloadables!
- python (tested on 3.7)
- Libre Office, or any .xlsx file editor
- C++11 or newer.
Who's who?
/python : Python scripts to run and analyze data cought from the hooks running in a specific mode. Read more inside.
/C : .cc and .h to include to enable custom malloc(), free() hooks on the C Library. Read more inside.
pics: Images used for README.md. (added to .gitignore)
tflite: Tensorflow Lite Micro (TFLite) optimized audio operators (MFCC and audio_spectrogram)
Getting started
To start using the scripts, clone the repo to a local dir.
- Place the c files into your TFLlite's main.cpp dir. (Complete CMakeLists.txt/Linker accordingly)
- Include the header files into your main.cpp to be used by the built TFLite bin.
- (Optional) If also using the above mentioned TFLite ops, please copy the files into tf/tflite/micro/kernel/
- Comment the line inside malloc_hook.h to start in default mode: (If already done skip.)
#define _STATIC_MALLOC
- Introduce memory hooks into main.cpp
- Compile (preferably in DEBUG mode) and run.
- Copy the important data into the clipboard.
- Use the python scripts in /python to analyze the memory data and generate offsets.
- Copy the offsets into malloc_array.cc
- Comment out the same line from step 4. to start in STATIC MODE.
- Compile and run.
- If uncontent with the results, repeat from step 4.
note: Inside each folder is a more extensive README concerning each theme. Please read carefully.