TL;DR
Researchers have developed a novel way to speed up Deep Neural Networks on ultra-low-power "edge" devices by fusing depthwise and pointwise convolutional layers. By optimizing how data is tiled and laid out in memory, they achieved up to an 11.4% reduction in latency and slashed activation memory transfers by nearly 53% on the GreenWaves GAP8 SoC.
What Problem Does This Paper Address?
Depthwise Separable Convolutions (DWSC) are the secret sauce behind efficient mobile AI models like MobileNet. They drastically reduce the number of mathematical operations (MACs) compared to standard convolutions. However, there is a catch: they have very low "data reuse."
On ultra-low-power microcontrollers (MCUs), the bottleneck isn't usually the processor's speed, but the cost of moving data. These devices typically use a multi-level memory hierarchy: a tiny, fast L1 scratchpad and a larger, slower L2 memory. Because DWSC layers don't reuse data much, the system spends a massive amount of time and energy shuffling intermediate results back and forth between L1 and L2. This paper tackles the "memory wall" by finding ways to keep data in the fast L1 memory longer through layer fusion.
Methods
The authors propose a set of six new fused kernels that combine the two parts of a DWSC block—the Depthwise (DW) and Pointwise (PW) layers—into a single execution step.
- Layer Fusion Strategies:
- DW-PW Fusion: They use row-wise tiling. Since the PW layer is a 1x1 convolution, it doesn't need to look at neighboring pixels, making it easy to process a few rows of DW output and immediately feed them into the PW layer without recomputing anything.
- PW-DW Fusion: This is trickier because the DW layer has a larger receptive field (e.g., 3x3). The authors explored both channel-wise tiling (leveraging the independence of DW channels) and row-wise tiling (using a shifting buffer to avoid redundant calculations).
- Data Layout Optimization: The team experimented with different ways to arrange data in memory (Height-Width-Channel vs. Channel-Height-Width). They found that using a specific layout for the intermediate buffer (CHW for DW inputs) avoids "strided loads," which are computationally expensive on these processors.
- DORY Compiler Extension: They integrated these kernels into DORY (Deployment Oriented to memoRY), an open-source tool. They added a "fusion engine" that automatically decides which layers to fuse based on memory constraints and a "post-processing optimizer" that picks the best combination of fused and unfused layers to minimize either latency or memory traffic.
Datasets
The researchers evaluated their approach using three popular efficient architectures:
- MobileNetV1 (MV1): Tested with various input resolutions (224x224, 128x128, and a 96x96 version for visual wakewords).
- MobileNetV2 (MV2): Tested at 224x224 and 128x128 resolutions.
- DSCNN: A keyword spotting network.
These models were deployed on the GreenWaves GAP8 SoC, a commercial multi-core RISC-V processor designed for the edge.
Key Insights and Ideas
- The Memory-Latency Trade-off: Fusing layers requires an intermediate buffer in the L1 memory. If this buffer is too large, it leaves less room for the actual input and output data, forcing the compiler to use smaller "tiles" and actually increasing memory transfers. The optimal "Fused Dimension" (FD) is a delicate balance.
- Layout Matters More Than You Think: The inherent stationary dataflow of the kernels means that loading input data is more "expensive" than storing output data. Therefore, layouts that favor efficient input loading (avoiding strided memory access) yield the best performance.
- Selective Fusion: The most surprising insight is that you shouldn't fuse everything. The authors' optimizer often chooses to leave the very first or very last layers unfused because their geometric properties (like having very few channels or very large spatial dimensions) make fusion inefficient.
Key Results
- End-to-End Speedup: On MobileNetV1-128, they achieved an 11.40% reduction in total latency.
- Massive Memory Savings: For MobileNetV2-128, they reduced activation data movements between L2 and L1 by 52.97%.
- Energy Efficiency: While not measured directly on the hardware, the authors estimate an energy reduction of up to 90.94% for models that previously required expensive external L3 memory access, simply by keeping the data within the L1/L2 hierarchy through fusion.
- Computational Overhead: The best-performing fused kernels added as little as 5.13% computational overhead compared to the theoretical ideal, proving that the implementation is highly efficient.
Limitations and Future Work
- Memory Constraints: The primary limitation is the L1 memory size. For very large feature maps or networks with a high number of channels (like the core of DSCNN), the intermediate buffer required for fusion can become a liability rather than an asset.
- Hardware Specifics: The current kernels are highly optimized for the GAP8's 8-bit SIMD extensions and multi-core RISC-V architecture. Porting these to other MCUs (like ARM Cortex-M) would require rewriting the inner assembly/intrinsics.
- Future Directions: The authors suggest that future work could explore fusing even longer sequences of layers (e.g., three or more) or applying these techniques to different types of layers beyond standard depthwise separable blocks.
Summary updated