Abstract
The proliferation of Internet of Things (IoT) devices has created a demand for deploying Deep Neural Networks (DNNs) on resource-constrained microcontrollers (MCUs). This paper presents an automated pipeline for shrinking DNNs through aggressive pruning and quantization, coupled with a custom "ahead-of-time" deployment tool optimized for ARM Cortex-M hardware. Our results demonstrate that popular architectures like AlexNet and ResNet can be compressed to less than 10% of their original size while maintaining high accuracy and significantly reducing energy consumption.
Introduction
Deep Learning models are traditionally resource-intensive, requiring significant memory and computational power. In contrast, microcontrollers typically offer less than 1MB of Flash and 256KB of RAM. This disparity necessitates specialized compression techniques that consider hardware-specific constraints such as SRAM limits, execution latency, and battery life. This research bridges the gap between high-level AI training and low-level hardware execution by providing a systematic methodology to explore multi-dimensional trade-offs in embedded AI.
Methodology: The Compression Pipeline
The proposed approach utilizes a two-stage pipeline to optimize models for deployment, balancing application-specific accuracy with architecture-specific constraints.
1. Application-Specific Compression
The first stage focuses on reducing the model's theoretical size through pruning and quantization. The authors evaluate both element-wise pruning (targeting individual weights) and structural pruning (removing entire filters or channels). To maintain accuracy during this process, an Automated Gradual Pruning (AGP) schedule is employed. Furthermore, the pipeline compares Post-Training Quantization (PTQ) with Quantization-Aware Training (QAT) to convert 32-bit floating-point weights into 8-bit integers.
2. Architecture-Specific Deployment
To execute these compressed models, the authors developed dnnruntime, an Ahead-of-Time (AOT) compilation tool. Unlike heavy interpreters, dnnruntime generates static C code and performs offline memory planning. By simulating the lifespan of data tensors, the tool reuses memory addresses, drastically reducing the SRAM footprint. For hardware acceleration, the runtime leverages the CMSIS-DSP library to utilize SIMD (Single Instruction, Multiple Data) instructions on Cortex-M4 processors.
Experimental Results
The pipeline was evaluated using AlexNet and ResNet on the CIFAR-10 dataset, and LeNet on the MNIST dataset. The experiments focused on the trade-off between relative accuracy and theoretical model size across various pruning heuristics.
As shown in the results, all three architectures could be compressed to less than 10% of their original parameter counts before experiencing significant accuracy degradation. Notably, Quantization-Aware Training (QAT) proved essential for maintaining performance at extreme compression levels (near 1% of original size). On an Arduino Nano 33 BLE (Cortex-M4), a quantized and structurally pruned LeNet was 2.3x faster and used 3.2x less energy per inference compared to the floating-point version.
Key Insights
- Structural Pruning for MCUs: While element-wise pruning offers higher theoretical sparsity, structural pruning is often more effective for microcontrollers. Removing entire filters simplifies the input shapes for subsequent layers, reducing RAM requirements for intermediate activations without the overhead of complex sparse-matrix mathematics.
- The Sparsity Threshold: Implementing Compressed Row Storage (CRS) for sparse weights only yields memory savings at extreme sparsity levels (>70-80%). Below this threshold, the metadata required for indexing can actually increase the model size.
- Energy Efficiency: Faster inference directly correlates with lower energy consumption. In the context of battery-powered MCUs, a "Race to Sleep" strategy—where the processor executes tasks as quickly as possible to return to a low-power state—is the most effective approach for extending battery life.
Conclusion
This work demonstrates that with the right combination of structural pruning, quantization-aware training, and hardware-optimized deployment tools, complex DNNs can be effectively deployed on low-power microcontrollers. Future research will explore integrating these techniques with Neural Architecture Search (NAS) and lower bit-width quantization (e.g., 4-bit or binary networks) to further push the boundaries of "TinyML."
Summary updated