Abstract
Mobile vision systems are increasingly required to execute multiple complex deep neural network (DNN) tasks simultaneously on resource-constrained hardware. Traditional model-grained scaling, which relies on a limited set of pre-defined model variants, often fails to efficiently utilize available system resources. This paper introduces LegoDNN, a framework that enables block-grained scaling. By decomposing DNNs into modular blocks and training multiple compressed versions of each, LegoDNN provides a massive configuration space for runtime optimization. Evaluation shows that LegoDNN achieves up to 31.74% higher inference accuracy and reduces energy overhead by 71.07% compared to traditional scaling methods.
Introduction
The deployment of deep learning on mobile devices, such as smartphones and drones, is hindered by strict constraints on memory, battery, and processing power. To adapt to fluctuating resource availability, current systems typically employ model-grained scaling. This approach involves switching between a few discrete versions of a model (e.g., small, medium, large). However, this method suffers from coarse granularity—wasting resources when available memory lies between two versions—and prohibitive training costs for each full-model variant.
LegoDNN addresses these limitations by shifting the scaling granularity from the entire model to its constituent blocks. This approach allows for a much finer-grained adaptation to available resources.
Methodology
The LegoDNN framework is divided into two primary stages: an offline generation stage and an online runtime scaling stage.
Offline Stage: Generation and Training
In the offline stage, LegoDNN identifies repeating structural patterns within a DNN, such as ResBlocks, and extracts them as "elementary blocks." For each block, the framework creates a specialized training environment using intermediate data from the original model. This allows multiple "descendant" (compressed) versions of each block to be trained independently and in parallel, drastically reducing the total training time to approximately 24% of traditional methods. Each descendant block is then profiled for accuracy loss, memory footprint, and latency on target hardware.
Online Stage: Runtime Scaling
At runtime, when system resources change, LegoDNN employs a scaling optimizer based on Integer Linear Programming (ILP). The optimizer identifies the mathematically optimal combination of block versions to maximize accuracy within current resource constraints. A block exchanger then performs the swap, replacing only the necessary components rather than the entire model.
Evaluation and Results
LegoDNN was evaluated using standard benchmarks including Cifar-10/100, ImageNet2012, and COCO2017 across 12 popular DNN architectures (e.g., VGG16, ResNet18, YOLOv3).
The key findings include:
- Granularity: LegoDNN offers between 1,296x and 279,936x more configuration options than baseline methods, allowing the model to closely match available memory.
- Accuracy: Under identical resource constraints, LegoDNN improved inference accuracy by up to 31.74% by utilizing previously wasted memory.
- Efficiency: The block-swapping mechanism reduced scaling energy consumption by 71.07%, as it avoids the overhead of loading entire new model files from storage.
Conclusion
LegoDNN represents a significant advancement in mobile DNN deployment by providing a flexible, "LEGO-like" approach to model scaling. By decoupling the learning process and optimizing at the block level, it achieves superior accuracy and energy efficiency. Future research may explore the integration of federated learning to train descendant blocks across distributed devices, further enhancing the framework's scalability and data privacy.
Summary updated