Efficient Latency-Aware CNN Depth Compression via Two-Stage Dynamic Programming

Jinuk Kim, Yeonwoo Jeong, Deokjae Lee, Hyun Oh Song

Introduction

Deploying Convolutional Neural Networks (CNNs) on edge devices with limited resources requires models with strictly low inference latency. Traditionally, researchers have relied on channel pruning (making the network narrower) to reduce computational overhead. However, on modern parallel hardware like GPUs, reducing the depth of a network (the number of sequential layers) is often much more effective for cutting down wall-clock inference time.

Recent "depth compression" methods, such as DepthShrinker, tackle this by removing non-linear activation layers (like ReLU) between convolutions. This allows adjacent linear convolutions to be mathematically merged into a single, shallower layer. The problem is that existing methods are highly restricted: they only look at specific architectural blocks (like MobileNet's Inverted Residual Blocks) and rely on human-engineered heuristics to decide what to merge. This paper introduces a generalized, mathematically optimal framework that can evaluate and merge any sequence of convolution operations across an entire network to maximize speed while preserving accuracy.

Methodology: Formulating the Optimization

The authors frame depth compression as an optimization problem governed by two key variables:

  1. $A$: The set of activation layers to keep (replacing the rest with identity functions).
  2. $S$: The set of boundaries where layers should not be merged.
Illustration of the depth compression process, showing the removal of ReLUs and merging of consecutive convolutions.

Because adjacent convolutions without an activation function between them can be collapsed into one, optimizing $A$ and $S$ dictates the final architecture. However, finding the perfect combination is NP-hard, as it would normally require exhaustively training and evaluating every possible network configuration.

To solve this efficiently, the authors introduce a surrogate objective. Instead of evaluating the whole network, they approximate the total accuracy drop as the linear sum of the accuracy drops caused by modifying individual, contiguous network blocks. With this approximation, the problem can be solved exactly using two-stage dynamic programming (DP):

  • Stage 1: Calculates the optimal merging strategy for every possible contiguous block to minimize latency.
  • Stage 2: Finds the optimal global combination of these blocks that maximizes accuracy under a strict user-defined latency budget.

The DP algorithm runs in just a few seconds. Afterward, the network's padding is carefully reordered to ensure mathematical equivalence, and the model is fine-tuned to recover accuracy.

Key Insights

  • Merging isn't always optimal: One of the paper's best insights is that merging layers doesn't always improve latency. For example, merging a 100-to-1 channel convolution with a 1-to-100 channel convolution results in a massive 100-to-100 channel convolution, which is drastically slower. Jointly optimizing both the activation removal ($A$) and the merge boundaries ($S$) prevents these latency traps, resulting in networks that are ~30% faster than naive merging.
  • Escaping Block Boundaries: Because the DP algorithm is agnostic to the network's human-designed architecture, it can find highly efficient, non-intuitive merges that cross traditional block boundaries—something previous heuristic methods completely miss.
  • Depth > Width for Latency: The paper reinforces a growing consensus that for real-world hardware efficiency and memory usage, reducing sequential operations (depth) is superior to reducing parallel operations (width/channels).

Key Results

The proposed method was evaluated on the ImageNet dataset, demonstrating superior speed and accuracy tradeoffs compared to existing baselines.

Performance comparison on ImageNet showing the proposed method outperforming DepthShrinker (DS) baselines.
  • Superior Speed and Accuracy: On the full ImageNet dataset using MobileNetV2-1.0, the proposed method achieved a 1.41x speedup (measured via TensorRT on an RTX 2080 Ti) with a 0.11%p accuracy gain over the pretrained baseline, aided by knowledge distillation.
  • Beating the State-of-the-Art: The method consistently outperformed the primary baseline, DepthShrinker, across various compression ratios, hardware platforms (RTX 2080 Ti, TITAN Xp, RTX 3090, Tesla V100, and Intel CPUs), and model formats.
  • Outperforming Channel Pruning: The depth-compressed models achieved better accuracy-latency tradeoffs than established channel pruning baselines like Uniform L1, AMC, and MetaPruning.
  • Generalizability: The method was successfully applied to VGG19, achieving a 1.44x speedup without any loss in accuracy, proving it works outside of mobile-specific architectures.

Limitations and Future Work

  • Approximation Gap: The surrogate objective assumes that the accuracy drop of the full network is simply the sum of the accuracy drops of individual blocks. While effective, this linear approximation ignores complex, cross-block interactions that might occur during fine-tuning.
  • Upfront Compute Cost: While the DP algorithm takes only seconds, preparing the data for it requires evaluating the importance of $O(N^2)$ possible network blocks. This involves training many deactivated sub-networks for a single epoch, which is a notable upfront computational cost.
  • Padding Restrictions: The exact merging technique currently limits considerations to zero-padding. Handling other types of padding or more complex skip-connection topologies (beyond simple residual additions) could be an area for future expansion.

Summary updated

BibTeX
@inproceedings{kim2023efficient,
  author = {Jinuk Kim and Yeonwoo Jeong and Deokjae Lee and Hyun Oh Song},
  title = {{Efficient Latency-Aware CNN Depth Compression via Two-Stage Dynamic Programming}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=JOrh26MBOT},
}
Figure