An Image Enhancing Pattern-Based Sparsity for Real-Time Inference on Mobile Devices

Xiaolong Ma, Wei Niu, Tianyun Zhang, Sijia Liu, Sheng Lin, Hongjia Li, Wujie Wen, Xiang Chen, Jian Tang, Kaisheng Ma, Bin Ren, Yanzhi Wang

Introduction

The deployment of large Deep Neural Networks (DNNs) on mobile devices is often constrained by the trade-off between model accuracy and hardware efficiency. Traditional pruning methods—non-structured and structured—either maintain accuracy at the cost of hardware speed or achieve speed at the cost of accuracy. This paper introduces pattern-based sparsity, a novel approach that achieves real-time inference on mobile devices while simultaneously improving model accuracy by leveraging mathematically inspired kernel shapes and a custom compiler.

Methodology: Pattern and Connectivity Sparsity

The proposed approach operates on two distinct levels of granularity to optimize the model for mobile hardware:

  1. Pattern Sparsity (Intra-kernel): Within each $3 \times 3$ convolution kernel, a fixed number of weights (e.g., 4 out of 9) are retained. These remaining weights are constrained to follow specific "patterns" from a predefined library.
  2. Connectivity Sparsity (Inter-kernel): This level removes entire kernels that connect less significant input and output channels, further reducing the computational load.
Overview of pattern-based and connectivity sparsity within a filter.

To implement this, the authors utilized the Alternating Direction Method of Multipliers (ADMM) optimization framework. This allows the model to dynamically select the most effective patterns from the library during the training process.

Compiler-Algorithm Co-design

A critical component of this research is the development of a custom compiler-assisted inference framework. Standard libraries like TFLite are not designed to exploit the fine-grained regularity of pattern-based sparsity. The custom compiler re-orders filters and kernels to group those with identical patterns. This grouping enables the effective use of Single Instruction, Multiple Data (SIMD) units on mobile CPUs and GPUs, maximizing throughput and eliminating the branch divergence typically associated with sparse models.

The choice of 4 non-zero weights per $3 \times 3$ kernel is specifically tailored to 128-bit SIMD registers, ensuring data is packed efficiently without wasted space.

Key Insights: Pruning as Feature Enhancement

Contrary to the view that pruning is a form of "damage control," this work suggests that forcing kernels into specific geometric shapes—such as crosses or diamonds—acts as a form of regularization. These patterns often resemble classical computer vision filters like Gaussian blurs or Laplacian of Gaussian edge detectors.

Visualization of learned 3x3 kernel patterns that resemble classical image processing filters.

By constraining the kernels, the model is encouraged to extract cleaner features, reducing noise and highlighting edges. This "steerable filter" effect explains why the pruned models often outperform their dense counterparts in terms of accuracy.

Evaluation and Results

The framework was evaluated on ImageNet and CIFAR-10 datasets using architectures such as VGG-16, ResNet-18/50, and MobileNet-V2. Testing on a Samsung Galaxy S10 (Snapdragon 855) yielded the following results:

  • Real-time Performance: Large models like VGG-16 and ResNet-50 achieved inference speeds exceeding 30 FPS.
  • Significant Speedups: The approach demonstrated a 15x-20x speedup over TFLite and TVM for VGG-16 on mobile GPUs.
  • Accuracy Improvements: Using a library of 8 patterns, the researchers observed a Top-1 accuracy increase of approximately 0.5% to 1% across various models, breaking the traditional trade-off between sparsity and precision.

Conclusion

Pattern-based sparsity represents a significant advancement in mobile DNN deployment. While currently focused on $3 \times 3$ kernels and visual tasks, future research could explore Neural Architecture Search (NAS) to discover optimal patterns for other domains. This work proves that algorithmic constraints, when co-designed with hardware-aware software, can lead to both faster and more accurate models.

Summary updated

BibTeX
@inproceedings{ma2020image,
  author = {Xiaolong Ma and Wei Niu and Tianyun Zhang and Sijia Liu and Sheng Lin and Hongjia Li and Wujie Wen and Xiang Chen and Jian Tang and Kaisheng Ma and Bin Ren and Yanzhi Wang},
  title = {{An Image Enhancing Pattern-Based Sparsity for Real-Time Inference on Mobile Devices}},
  booktitle = {European Conference on Computer Vision},
  year = {2020},
  doi = {10.1007/978-3-030-58601-0\_37},
}
Figure