A framework for measuring the energy consumption of a MCU during the execution of pruned TensorFlow-Lite models.
This framework provides Jupyter Notebooks to create LeNet-5 like pruned convolutional neural networks with different compression rates. Furthermore, the framework provides Jupyter Notebooks to convert the models into the required TensorFlow-Lite format. For measuring the energy consumption during execution, the framework provides a Python script to generate current traces. For analyzation purpose, the framework includes scripts to analyze the measured current traces.
The framework supports the Raspberry Pi Pico which uses an Arm-Cortex M0+ architecture.
This project was developed in the course of a bachelor thesis. The goal was to answer the following research questions:
- RQ1: How does unstructured pruning affect energy consumption?
- RQ2: How does structured pruning affect energy consumption?
The framework on one hand, provides Jupyter Notebooks to create pruned models from scratch and on the other hand, it provides pre-trained and pruned models with different compression rates and pruning approaches.
All pre-trained models are located in Models. The models are saved as .h5 files and start with a prefix indicating the compression rate. Section Create TFL model in this Jupyter Notebook is used to convert the pre-trained model into a TFL model required by the RPP.
To create pruned models from scratch, the framework provides the following Jupyter Notebook.
For tracing the current consumption of the RPP during execution, the framework provides the following Python script. The script automatically executes the classification on the RPP and traces the current in parallel. After tracing, the script saves the measured data in .csv files.
The framework provides a C++ environment that allows to easily send image data to the Raspberry Pi Pico, do the classification and receive the probabilities.
The project uses cmake as build environment.
Preparation: Before you start building this project, make sure you have the required tool chain installed.
sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlibFurthermore, you have to clone the pico-sdk repository and set the PICO_SDK_PATHenvironemt variable properly.
A good step-by-step manual can be found here: PICO-SDK
Build:
- pull this project
git clone https://github.com/widmannthomas/convolutional_neural_network_energy_improvement.git
cd convolutional_neural_network_energy_improvement- init git submodules
git submodule init
git submodule update- create a build directory
mkdir build
cd build- run cmake
cmake ..- build sub-modules
cd src/mnist
make- Copy binary to Raspberry Pi Pico Volume
cp mnist.uf2 <RPP TARGET>The following images are showing the experiment setup using the Raspberry Pi Pico.
