A Compression-Compilation Co-Design Framework Towards Real-Time Object Detection on Mobile Devices

Yuxuan Cai, Geng Yuan, Hongjia Li, Wei Niu, Yanyu Li, Xulong Tang, Bin Ren, Yanzhi Wang

Abstract

Deploying state-of-the-art object detection models like YOLOv4 on mobile devices is challenging due to their high computational demands. This paper introduces a compression-compilation co-design framework that combines a novel fine-grained structured pruning method with compiler-level optimizations. By dividing weight matrices into blocks and applying structured pruning within them, the framework achieves a 14x compression rate and a 5.5x speedup over the original YOLOv4. The resulting model runs at 17 FPS with 48.9 mAP on an off-the-shelf smartphone, demonstrating the feasibility of real-time, high-accuracy vision tasks on edge hardware.

Introduction

Modern object detection faces a significant trade-off: models are either highly accurate but computationally prohibitive for mobile deployment (e.g., YOLOv4), or they are lightweight but suffer from substantial accuracy loss (e.g., YOLO-Lite). Traditional weight pruning techniques attempt to bridge this gap but face limitations. Unstructured pruning creates irregular memory access patterns that hinder hardware acceleration, while coarse structured pruning (removing entire filters) often leads to severe accuracy degradation. Furthermore, pattern-based pruning is typically restricted to 3x3 kernels, limiting its effectiveness in modern networks that rely heavily on 1x1 convolutions.

Methodology

Fine-Grained Structured Pruning

The core of the proposed framework is a block-based pruning strategy. Instead of pruning individual weights or entire filters, the authors divide the 2D weight matrix of a layer into equal-sized blocks (e.g., 8x4). Within these blocks, entire rows or columns are pruned. This approach provides a finer granularity than traditional structured pruning, preserving model accuracy while maintaining the structural regularity required for efficient hardware execution.

Figure 1: Illustration of the 4-D weight tensor and its 2-D matrix representation for block-based pruning.

Crucially, this method is universal, applying to 3x3 convolutions, 1x1 convolutions, and fully connected layers. This bypasses the "3x3 ceiling" of pattern-based methods, allowing for much higher overall compression rates.

Compiler Optimization

To translate pruning into actual speedups, the framework introduces a Blocked Compressed Storage (BCS) memory format. BCS exploits the fact that block-based pruning preserves non-zero weights in identical columns within a block, using hierarchical compression to reduce the memory footprint of indices. Additionally, the compiler reorders computations to balance the load across CPU/GPU threads, further reducing latency.

Experimental Results

Evaluation was performed on the MS COCO dataset using a Samsung Galaxy S20 (Snapdragon 865). The optimized YOLOv4 achieved 48.9 mAP at 17 FPS, representing a 5.5x speedup over the original model. The framework reduced the model size by 14x (from 64.36M to 4.59M weights) and FLOPs by nearly 9x.

The Block Size Trade-off

A critical finding is the impact of block size on the Pareto front of accuracy and speed. Smaller blocks (e.g., 4x4) offer higher accuracy but lower hardware parallelism, whereas larger blocks (e.g., 32x4) maximize speed at the cost of precision.

Figure 5: The trade-off between mAP and FPS across different block sizes.

As shown in the results, an 8x4 block size provides an optimal balance for real-time mobile deployment. Furthermore, the authors found that pruning 3x3 layers slightly more aggressively than 1x1 layers yields better overall performance than uniform pruning.

Conclusion

The compression-compilation co-design framework successfully enables real-time YOLOv4 on mobile devices. By moving beyond the limitations of kernel-specific pruning and utilizing hardware-aware compiler optimizations, the framework outperforms standard "tiny" model variants in both accuracy and inference speed. Future work may involve automating the selection of block sizes and pruning rates through Neural Architecture Search (NAS).

Summary updated

BibTeX
@inproceedings{cai2021compression,
  author = {Yuxuan Cai and Geng Yuan and Hongjia Li and Wei Niu and Yanyu Li and Xulong Tang and Bin Ren and Yanzhi Wang},
  title = {{A Compression-Compilation Co-Design Framework Towards Real-Time Object Detection on Mobile Devices}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2021},
  doi = {10.1609/aaai.v35i18.17992},
}
Figure