High Performance Convolution Using Sparsity and Patterns for Inference in Deep Convolutional Neural Networks

Hossam Amer, Ahmed H. Salamah, Ahmad Sajedi, En-Hui YangarXiv 2021

Abstract

Convolutional operations represent the primary computational bottleneck in Deep Convolutional Neural Networks (CNNs), often accounting for 70-90% of total inference time. This paper introduces two novel algorithms, Compressed Pattern Overlap (CPO) and Compressed Pattern Sets (CPS), designed to exploit the inherent sparsity in activation maps. By eliminating redundant data storage in overlapping kernel regions and employing pattern-based index compression, these methods achieve significant performance gains. Experimental results on prominent architectures like ResNet and Inception demonstrate up to 63% per-layer speedups and 26x memory compression while maintaining full mathematical equivalence to standard convolution.

Introduction

The standard approach for implementing convolution in deep learning frameworks is the im2col (image-to-column) algorithm. This method "lowers" 3D activation maps into a 2D matrix, allowing the use of highly optimized General Matrix-to-Matrix Multiplication (GEMM) libraries. However, im2col suffers from two major inefficiencies. First, it introduces significant data redundancy by storing the same input elements multiple times as the kernel slides across the image. Second, it is "sparsity blind," treating every element equally despite the fact that ReLU activation functions typically result in 50-95% of activation maps being zero.

While much research has focused on weight pruning, this work targets input activations, which are often larger and highly sparse during real-time inference. The proposed CPO and CPS algorithms address these inefficiencies by storing only non-zero elements (NZEs) and optimizing their access patterns.

Methodology: CPO and CPS

The proposed approach consists of two primary techniques designed to handle sparse activation maps efficiently.

Compressed Pattern Overlap (CPO)

CPO avoids the data duplication inherent in im2col. Instead of replicating data for every overlapping kernel position, CPO identifies NZEs and stores them a single time. It utilizes a specialized indexing system consisting of pointers (ptr), data arrays (DA), and index arrays (IN). By categorizing kernel overlaps (e.g., horizontal or vertical), CPO ensures that each NZE is only processed in the specific output regions where it contributes, significantly reducing memory footprint and redundant computations.

Compressed Pattern Sets (CPS)

Building upon CPO, CPS leverages the observation that non-zero activations often appear in spatial clusters. Rather than storing individual indices, CPS groups indices into sets (e.g., blocks of four) and uses a 4-bit binary mask (a "pattern set") to represent which elements within that set are non-zero. This bitmask-based approach drastically reduces the memory overhead required for index metadata.

Overview of CPO/CPS indexing and computation mechanism.

Hybrid Selection

Because sparse operations can occasionally be slower than dense GEMM if the data density is too high, the authors implement a hybrid selection strategy. Through offline profiling with a small representative dataset, the system measures the average density of each convolutional layer. It then automatically selects the most efficient algorithm—CPO, CPS, or standard im2col—for each specific layer in the network.

Experimental Evaluation

The algorithms were evaluated using 100 randomly sampled images from the ImageNet dataset across six major CNN architectures: ResNet-V2 (50, 101, 152) and Inception (V1, V3, V4).

Performance and Compression

The effectiveness of CPO and CPS is closely tied to the sparsity (density) of the activation maps. As shown in Figure 2, layers with lower density exhibit the highest time savings and compression ratios.

Time savings and compression ratios (CR) across various CNN layers relative to activation density.

Key results include:

  • Speedups: Per-layer time savings reached up to 63%. For full end-to-end models, total inference time was reduced by up to 9%.
  • Memory Efficiency: The Compression Ratio (CR) reached up to 26x compared to im2col. Even when compared to other memory-efficient methods like MEC, CPO/CPS provided up to 9.2x better compression in specific layers.
  • Algorithm Distribution: In a hybrid configuration, the sparse algorithms were selected for approximately 56% of all non-pointwise convolutional layers, demonstrating broad applicability.

Key Insights

A critical finding of this research is stationary sparsity: the density of a specific convolutional layer remains remarkably stable across different input images. This stability allows for effective offline algorithm selection, avoiding the overhead of dynamic decision-making during inference. Furthermore, because CPO and CPS are mathematically identical to standard convolution, they provide these performance benefits without requiring model retraining or sacrificing accuracy.

Conclusion and Future Work

CPO and CPS offer a robust solution for accelerating CNN inference by targeting activation sparsity and eliminating data redundancy. While highly effective for sparse layers, these methods can face overhead challenges in very dense layers (>60% density), where traditional GEMM remains superior. Future work will focus on extending these sparse patterns to parallel GPU implementations and evaluating their performance on lightweight "mobile" architectures like MobileNet.

Summary updated

BibTeX
@misc{amer2021high,
  author = {Hossam Amer and Ahmed H. Salamah and Ahmad Sajedi and En-Hui Yang},
  title = {{High Performance Convolution Using Sparsity and Patterns for Inference in Deep Convolutional Neural Networks}},
  year = {2021},
  eprint = {2104.08314},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.08314},
}
Figure