TL;DR
This paper introduces CompactNet, a novel framework that automatically optimizes pre-trained Convolutional Neural Networks (CNNs) for specific hardware platforms to achieve a target inference speedup while preserving accuracy. By using a platform simulator, CompactNet intelligently prunes redundant filters, enabling efficient CNN deployment on resource-constrained devices like smartphones.
What Problem Does This Paper Address?
Deploying deep learning models, particularly Convolutional Neural Networks (CNNs), on resource-limited devices like smartphones presents a significant challenge. CNNs are computationally intensive, and their performance varies drastically across different hardware architectures (e.g., mobile CPUs vs. specialized NPUs). Existing optimization techniques often lack platform awareness, meaning a model optimized for one platform might not perform optimally on another. Manually tuning these models requires deep, often unavailable, expertise about the target hardware. This paper addresses the need for an automated, platform-aware method to optimize CNNs for specific inference speed targets without requiring detailed hardware knowledge.
Methods
CompactNet employs a two-pronged approach: a platform simulator and an automatic searching algorithm.
- Platform Simulator: This component is the core of CompactNet's platform-aware nature. Instead of needing direct access to the hardware, it simulates the kernel computation latency of CNN layers on the target platform. This is achieved by collecting latency data for each layer with varying input and output channels on the actual hardware and then using this data to predict the latency of trimmed models. This simulator acts as a "black-box" interface to the hardware.
- Automatic Searching Algorithm: This algorithm iteratively prunes a pre-trained CNN. The optimization is broken down into
Niterations, each with a sub-target speedup. In each iteration, the algorithm generates multiple candidate models by trimming filters from a single layer. The trimming process prioritizes removing filters with the smallest L2-norm magnitude. After trimming, a short-term fine-tuning step is performed to restore accuracy. The candidate model that best meets the sub-target speedup with the least accuracy loss is selected for the next iteration. Once all iterations are complete, a final retraining step is performed to produce the optimal, platform-specific model.
Datasets
- Cifar-10: Used for pre-training the original MobileNetV2 model and for evaluating the performance of the optimized models.
Key Insights and Ideas
- Platform-Specific Optimization is Crucial: The paper strongly demonstrates that optimal CNN models are inherently platform-specific. An optimized model for a mobile CPU does not perform optimally on an NPU, and vice-versa, even for the same speedup target.
- Simulator as a Hardware Abstraction: The platform simulator effectively abstracts away the complexities of hardware architecture, allowing for platform-aware optimization without deep hardware expertise. This makes the approach generalizable to various platforms.
- Filter Pruning for Speedup: CompactNet focuses on removing entire filters (output channels) rather than individual weights. This approach is more direct and effective for achieving significant speedups on hardware.
- Accuracy Preservation through Fine-tuning: The iterative fine-tuning and final retraining steps are critical for ensuring that the aggressive pruning does not lead to a substantial drop in accuracy. In some cases, accuracy can even be slightly improved.
Key Results
CompactNet was evaluated on a Huawei Mate10 smartphone using two processors: a mobile ARM CPU and a Cambricon-1A NPU. The experiments used the MobileNetV2 model.
- Mobile CPU: Achieved up to a 1.8x kernel computation speedup with equal or slightly higher accuracy on Cifar-10. Compared to other state-of-the-art methods like NetAdapt, MorphNet, and ADC, CompactNet showed superior performance in terms of both speedup and accuracy.
- NPU Accelerator: Achieved a 1.3x speedup with improved accuracy and a 1.5x speedup with slightly reduced accuracy. The results highlight the platform-specific nature of the optimized models.
- Simulator Validation: The platform simulator demonstrated high accuracy in predicting real latency, with a sufficiently small difference between simulated and real latency values.
Limitations and Future Work
- Trimming Approach: The paper notes that the filter selection method (L2-norm magnitude) and the overall trimming approach are not the only options. Future work could explore more sophisticated pruning techniques, such as reinforcement learning, for finer-grained optimization.
- Hyperparameter Tuning: The performance of CompactNet is influenced by hyperparameters like
N(number of iterations) andd(decay rate). While the paper provides settings for the tested platforms, further research could investigate more adaptive or automated ways to set these parameters. - Generalizability: While the simulator is designed to be general, the effectiveness of CompactNet on a wider range of CNN architectures and hardware accelerators would be an interesting area for future exploration.
Summary updated