Accelerating Convolutional Neural Network by Exploiting Sparsity on GPUs

Weizhi Xu, Yintai Sun, Shengyu Fan, Hui Yu, Xin Fu

Abstract

Convolutional Neural Networks (CNNs) are foundational to modern deep learning, yet the convolution operation remains a primary computational bottleneck. This paper identifies two key inefficiencies in standard CNN implementations: the redundant calculation of zero-valued pixels in sparse feature maps and the frequent data transfer between CPU and GPU caused by separate convolution and pooling layers. To address these, we propose two novel methods. First, we introduce the Extended and Compressed Row (ECR) format, which accelerates convolution by skipping zero values. Second, we propose the Pooling-pack ECR (PECR) format, which fuses convolution and pooling operations to reduce memory traffic. Experimental results on architectures like VGG-19, ResNet-50, and DenseNet-121 demonstrate significant speedups, achieving up to 2.74× improvement over the NVIDIA cuDNN library.

Introduction

In a typical deep learning model, the convolution operation is the heavy lifter, often consuming over 70% of the total execution time. However, much of this work is actually redundant. Thanks to activation functions like ReLU and techniques like network pruning, feature maps in deep layers are often incredibly sparse—sometimes over 80% of the values are zero. Standard libraries like cuDNN usually treat these maps as dense, performing multiplications and additions on zeros that don't change the final result. While general sparse libraries exist, they often struggle with the specific data access patterns of GPUs, creating memory bottlenecks. Furthermore, traditional frameworks treat convolution and pooling as separate steps, forcing unnecessary data movement between GPU memory and the processor.

Methods

The authors propose a two-pronged strategy to tackle both computational waste and memory overhead:

  1. Extended and Compressed Row (ECR) Format: This is a new way to store feature maps. Instead of a standard grid, ECR only stores non-zero values and their locations. Crucially, it allows the GPU to perform a variant of Sparse Matrix-Vector multiplication (SpMV) in a single pass through global memory. One GPU thread is assigned to one convolution result, skipping all zeros in its window.
  2. Pooling-pack ECR (PECR) Format: This takes ECR a step further by "fusing" the convolution and pooling layers. Instead of calculating a full convolution map and then pooling it, PECR calculates only the values needed for the pooling result in one go, eliminating intermediate storage in global memory.
  3. Optional Convolution and Pooling Algorithm (OCPA): Since not every convolution layer is followed by a pooling layer, OCPA dynamically chooses between ECR and PECR based on the network's architecture.
Illustration of the ECR format extraction and extended kernel multiplication process.

Key Insights and Ideas

  • The "Deeper is Sparser" Rule: Empirical analysis confirms that as data moves deeper into a network, sparsity increases significantly. This makes sparse-aware methods most effective in the layers where computation is usually most expensive.
  • Memory Access Optimization: Skipping math isn't enough; memory access is the real bottleneck. ECR’s "one-time access" design is what allows it to beat highly optimized dense libraries by minimizing trips to global memory.
  • Reducing Bank Conflicts: By extending the filter (kernel) data alongside the feature map in shared memory, the implementation ensures that multiple GPU threads can access data simultaneously without shared memory bank conflicts.
Sparsity of feature maps across convolution layers for various VGG architectures, showing increasing sparsity in deeper layers.

Key Results

The proposed OCPA method consistently outperformed both cuDNN (dense) and cuSPARSE (sparse) across various models:

  • VGG-19: 1.97× speedup over cuDNN.
  • ResNet-50: 2.23× speedup over cuDNN.
  • DenseNet-121: 2.74× speedup over cuDNN.
  • RegNetX-16GF: 1.58× speedup over cuDNN.

When compared specifically to cuSPARSE, the ECR method alone achieved speedups ranging from 1.35× to 2.35×, proving that this custom storage format is significantly more efficient for CNN-specific workloads than general sparse libraries.

Conclusion and Future Work

While the proposed methods offer substantial gains, speedups tend to decrease as batch size increases due to cuDNN's extreme optimization for massive parallelism. Additionally, the initial transformation of dense feature maps into ECR still incurs overhead. Future research directions include baking sparse-aware logic directly into hardware to eliminate software conversion costs and extending these techniques to broader multi-channel convolution scenarios.

Summary updated

BibTeX
@article{xu2019accelerating,
  author = {Weizhi Xu and Yintai Sun and Shengyu Fan and Hui Yu and Xin Fu},
  title = {{Accelerating Convolutional Neural Network by Exploiting Sparsity on GPUs}},
  journal = {ACM Trans. Archit. Code Optim.},
  year = {2019},
}
Figure