GRIM: A General, Real-Time Deep Learning Inference Framework for Mobile Devices based on Fine-Grained Structured Weight Sparsity

Wei Niu, Zhengang Li, Xiaolong Ma, Peiyan Dong, Gang Zhou, Xuehai Qian, Xue Lin, Yanzhi Wang, Bin Ren

Abstract

The deployment of state-of-the-art Deep Neural Networks (DNNs) on mobile devices is hindered by the significant computational and memory requirements of these models. While weight pruning is a standard technique to reduce model size, it often involves a trade-off between the high accuracy of irregular, non-structured pruning and the hardware efficiency of coarse-grained structured pruning. This paper presents GRIM, a comprehensive framework that introduces Block-based Column-Row (BCR) sparsity. BCR pruning offers a "middle ground" by enforcing fine-grained structure within weight blocks, allowing for both high accuracy and efficient hardware execution. Coupled with a specialized compiler stack that optimizes memory access and thread synchronization, GRIM achieves up to 14x speedups over industry-standard frameworks like TensorFlow-Lite and TVM. We demonstrate that GRIM enables real-time inference (30+ FPS) for large models like VGG-16 on commodity smartphones.

The Challenge of Weight Pruning

Running modern DNNs on mobile devices presents a classic conflict between model complexity and resource constraints. To bridge this gap, researchers typically employ weight pruning—the removal of redundant connections within a network. However, a frustrating trade-off persists between two dominant paradigms:

  1. Non-structured pruning: This method removes weights arbitrarily across the network. While it preserves high accuracy, it creates irregular data structures that are poorly suited for the parallel, block-based processing architectures of mobile CPUs and GPUs.
  2. Coarse-grained structured pruning: This approach removes entire filters or channels. While highly hardware-friendly, it often leads to significant accuracy degradation, particularly in Recurrent Neural Networks (RNNs) where every connection can be critical.
Comparison of weight pruning strategies, highlighting the spectrum from non-structured to fine-grained structured approaches.

GRIM seeks to resolve this by identifying a fine-grained structured sparsity that offers the accuracy of irregular pruning with the execution speed of structured methods.

The GRIM Framework

The core innovation of GRIM is a two-pronged approach involving a novel sparsity scheme and a specialized compiler stack.

Block-based Column-Row (BCR) Pruning

Instead of pruning the entire weight matrix globally, GRIM partitions it into smaller $n \times m$ blocks. Within each block, independent row and column pruning is performed. This strategy constrains the "search space" for the pruning algorithm, making it easier to identify high-accuracy sparse configurations that still maintain enough local regularity for hardware to exploit. The framework utilizes the Alternating Direction Method of Multipliers (ADMM) to mathematically ensure the pruning process converges on an optimal sparse model.

The GRIM Compiler Stack

Pruning alone cannot achieve real-time speeds; it requires software that can efficiently skip zero-valued weights. The GRIM compiler includes several key optimizations:

  • Matrix Reordering: Rows with similar sparse patterns are grouped together to minimize thread divergence on GPUs, ensuring processing cores spend less time waiting for one another.
  • BCRC Storage Format: A specialized "Blocked Column-Row Compact" format is introduced, which is significantly more memory-efficient than standard formats like Compressed Sparse Row (CSR).
  • Register Load Redundancy Elimination (LRE): This technique maximizes the reuse of data within the processor's fastest memory (registers), reducing the frequency of expensive main memory accesses.

Experimental Evaluation

The authors evaluated GRIM using mainstream benchmarks including ImageNet and CIFAR-10 for CNNs (VGG-16, ResNet-18, MobileNet-V2) and the TIMIT dataset for GRU-based RNNs.

Key Results

  • Performance Gains: On a mobile GPU (Adreno 640), GRIM achieved speedups of up to 14.08x compared to TensorFlow-Lite and TVM.
  • Real-Time Execution: GRIM successfully executed the VGG-16 model on a smartphone in just 33ms, meeting the industrial real-time standard of 30 frames per second (FPS). In comparison, standard TFLite required over 300ms for the same task.
  • Efficiency vs. Specialized Hardware: When tested on RNNs, GRIM matched the performance of ESE (a specialized FPGA-based framework) while delivering 38x higher energy efficiency.
  • Sparsity and Accuracy: On CIFAR-10, the framework achieved a 50.5x pruning rate on VGG-16 with zero loss in accuracy.

Conclusion and Future Work

GRIM demonstrates that hardware regularity does not need to be global to be effective. By enforcing structure at the block level and co-designing the pruning strategy with the compiler, GRIM provides a unified acceleration path for both CNNs and RNNs.

While highly effective, the authors note that extremely deep models like Transformers (e.g., BERT) present new challenges. Preliminary studies show a 1.8x pruning rate on BERT-base without accuracy loss, suggesting that extending the BCR scheme to attention-based mechanisms is a promising direction for future research. Additionally, the current framework requires an offline profiling stage on the target device, which the authors aim to further automate in future iterations.

Summary updated

BibTeX
@article{niu2022grim,
  author = {Wei Niu and Zhengang Li and Xiaolong Ma and Peiyan Dong and Gang Zhou and Xuehai Qian and Xue Lin and Yanzhi Wang and Bin Ren},
  title = {{GRIM: A General, Real-Time Deep Learning Inference Framework for Mobile Devices based on Fine-Grained Structured Weight Sparsity}},
  journal = {IEEE Trans. Pattern Anal. Mach. Intell.},
  year = {2022},
  doi = {10.1109/tpami.2021.3089687},
}
Figure