Abstract
Deploying Deep Neural Networks (DNNs) on resource-constrained microcontrollers (MCUs) is often hindered by the significant memory requirements of intermediate feature maps. While patch-based fusion has emerged as a viable strategy to reduce peak RAM usage, existing methods often rely on heuristics or are limited to single-stage fusion. This paper introduces msf-CNN, a graph-based optimization framework that models CNN deployment as a Directed Acyclic Graph (DAG) to find mathematically optimal multi-stage fusion paths. By balancing memory savings against recomputation overhead, msf-CNN achieves up to a 50% reduction in peak RAM usage compared to state-of-the-art methods like MCUNetV2, enabling the deployment of complex models on hardware with as little as 16 KiB of RAM without any loss in accuracy.
Introduction
The rise of the Artificial Intelligence of Things (AIoT) has created a profound hardware-software gap. Modern lightweight DNNs, such as MobileNetV2 or ResNet-34, are designed to be efficient but still require hundreds of kilobytes of RAM to store activation tensors. In contrast, many ubiquitous microcontrollers (MCUs) are constrained to less than 50 KiB of available RAM. To bridge this gap, researchers have turned to "patch-based fusion," a technique that processes data in small tiles (patches) rather than entire feature maps. However, managing the trade-offs between memory reduction and the computational penalty of overlapping pixels remains a significant challenge.
The Patch-Based Fusion Challenge
In standard CNN execution, an entire layer's output must be stored in RAM before the next layer can begin processing. Patch-based fusion mitigates this by fusing multiple layers into a single processing block. Instead of computing the whole tensor, the system computes a small patch through all fused layers before moving to the next patch.
While this drastically reduces the peak RAM required for activations, it introduces a "recomputation penalty." Because convolutional filters have a receptive field that overlaps, the pixels at the edges of patches must be recalculated to ensure mathematical consistency. Previous approaches often limited fusion to the initial layers of a network or utilized hardware-specific optimizations that lacked generalizability. The core problem addressed by msf-CNN is determining the optimal depth, location, and number of fusion stages to minimize RAM or latency.
The msf-CNN Framework
Graph-Based Modeling
msf-CNN treats the search for an optimal deployment strategy as a classic graph theory problem. The framework represents a CNN as a Directed Acyclic Graph (DAG) where nodes represent tensors and edges represent operations (e.g., convolution, pooling). The researchers introduce "shortcut" edges to the graph, representing potential fusion blocks—sequences of layers that can be combined into a single patch-based unit.
Dual Optimization and Pruning
The framework addresses two primary optimization objectives:
- P1: Minimize peak RAM usage given a maximum allowable computation overhead.
- P2: Minimize computation cost (latency) given a strict RAM budget.
Finding the optimal path in such a graph is theoretically NP-hard ($O(2^N)$). To make this practical, msf-CNN employs a pruning strategy that iteratively removes edges with the highest RAM usage. This reduces the search complexity to polynomial time ($O(V^3)$), allowing the framework to find optimal configurations for deep networks in seconds.
Iterative Operators
Beyond standard convolutional layers, msf-CNN introduces redesigned Global Average Pooling and Dense (fully connected) layers. By processing these layers iteratively rather than requiring the entire input tensor to be resident in memory, the framework reduces the memory footprint of these specific operations to as little as 2% of their original size.
Experimental Results
Benchmarks and Models
The researchers evaluated msf-CNN using standard TinyML benchmarks, including ImageNet for accuracy verification and Visual Wake Words (VWW) for person-detection tasks. They tested several model variants, including MobileNetV2 (w0.35) and MCUNet (MN2-vvw5, MN2-320K), to demonstrate scalability.
Performance Metrics
- RAM Savings: msf-CNN achieved a reduction in peak RAM usage of 65% to 87% compared to non-fused baseline models.
- State-of-the-Art Comparison: When compared against leading methods like MCUNetV2 and StreamNet, msf-CNN used 50% less RAM for the same models.
- Extreme Deployment: The framework successfully deployed a MobileNetV2 model onto a SiFive hifive1b board, which possesses only 16 KiB of RAM. This level of efficiency was previously considered unattainable for this class of model.
- Zero Accuracy Loss: Because msf-CNN optimizes scheduling and memory management rather than modifying the weights or architecture (unlike pruning or quantization), the model's output remains identical to the original version.
Key Insights
The study reveals that "Multi-Stage" fusion is the critical factor in efficiency. While prior work often focused on a single large fusion block at the start of a network, msf-CNN demonstrates that multiple smaller fusion stages distributed throughout the network are often more effective. Furthermore, because the framework generates standard C-code via microTVM, it remains hardware-agnostic, performing effectively across ARM Cortex-M, RISC-V, and ESP32 architectures.
Conclusion and Future Work
msf-CNN provides a mathematically grounded approach to DNN deployment on ultra-low-power hardware. By converting the deployment challenge into a shortest-path problem on a DAG, it allows designers to navigate the Pareto frontier of memory and latency. Future work will focus on integrating more complex 2-D caching strategies and extending the framework to support non-convolutional architectures such as RNNs, LSTMs, and Transformers for edge-based audio and time-series analysis.
Summary updated