DYNAMAP: Dynamic Algorithm Mapping Framework for Low Latency CNN Inference

Yuan Meng, Sanmukh R. Kuppannagari, Rajgopal Kannan, Viktor K. Prasanna

TL;DR

DYNAMAP is a co-optimization framework that slashes CNN inference latency on FPGAs by dynamically mapping the most efficient convolution algorithm (im2col, kn2row, or Winograd) to each individual layer. By exploiting the inherent "series-parallel" structure of modern neural networks, DYNAMAP solves a massive combinatorial optimization problem in polynomial time to find the global optimal hardware-software mapping.

What Problem Does This Paper Address?

As Convolutional Neural Networks (CNNs) evolve, they are becoming increasingly heterogeneous. Modern architectures like Inception-V4 or GoogleNet feature layers with wildly different shapes, strides, and computation requirements.

Most existing FPGA accelerators use a "one-size-fits-all" approach, applying a single convolution algorithm and a fixed hardware dataflow across the entire network. This leads to two major inefficiencies:

  1. Algorithm Mismatch: An algorithm that excels at large filters (like Winograd) might be incredibly wasteful for $1 \times 1$ convolutions.
  2. Hardware Under-utilization: Fixed systolic arrays often suffer from "zero-padding" waste when layer dimensions don't perfectly align with the hardware's fixed parallelism.

The challenge is that choosing the best algorithm for every layer in a deep network is an NP-hard problem in general, with billions of possible combinations.

Methods

DYNAMAP tackles this through a two-pronged "hardware-architecture co-optimization" approach:

1. The Unified Hardware Overlay

The authors designed a flexible hardware template for FPGAs that can be reused across all layers. Key features include:

  • Algorithm Switching: Low-overhead modules that allow the hardware to switch between im2col (standard GEMM), kn2row (memory-efficient), and Winograd (computation-efficient) algorithms on the fly.
  • Stall-free PE Design: Processing Elements (PEs) that support multiple dataflows (Weight-Stationary, Input-Stationary, etc.) and can switch between them without incurring idle cycles.
  • Data Layout Transformation (DLT): A dedicated module that reorders data in memory between layers so that the output of one algorithm (e.g., Winograd) is correctly formatted as the input for the next (e.g., kn2row).

2. Software Design Space Exploration (DSE)

To find the best mapping, the authors treat the CNN as a graph. They prove that most popular CNNs are series-parallel graphs. This is a crucial insight because it allows them to use a polynomial-time reduction algorithm to find the mathematically optimal algorithm-to-layer mapping, bypassing the exponential complexity of a brute-force search.

Datasets

The framework was evaluated using two state-of-the-art, complex CNN models:

  • GoogleNet (22 layers)
  • Inception-V4 (141 layers)

The hardware implementation was tested on a Xilinx Alveo U200 FPGA board.

Key Insights and Ideas

  • The "Series-Parallel" Breakthrough: The most significant "aha moment" is the realization that CNN structures aren't just arbitrary directed acyclic graphs (DAGs); they follow patterns that make complex optimization problems tractable. This allows DYNAMAP to find a global optimum for a 141-layer network in under two seconds.
  • Dataflow is as Important as Algorithm: It’s not just about how you multiply matrices (the algorithm), but where the data stays (the dataflow). By allowing the hardware to switch between Weight-Stationary and Non-Stationary modes, they significantly boost effective PE utilization.
  • Bridging the Gap: DYNAMAP effectively bridges the gap between highly specialized, rigid hardware (fast but inflexible) and general-purpose processors (flexible but slow).

Key Results

DYNAMAP demonstrates significant performance gains over state-of-the-art fixed-algorithm FPGA implementations:

  • Speedup: Achieved up to 2.8× speedup for GoogleNet and 1.4× speedup for Inception-V4 in end-to-end inference latency.
  • Efficiency: The framework improved effective PE utilization by minimizing zero-padding and matching the hardware dataflow to the specific layer shape.
  • Optimization Speed: The software tool identifies the optimal configuration for even the deepest networks (like Inception-V4) almost instantaneously.

Limitations and Future Work

  • Algorithm Library: Currently, the framework supports three primary GEMM-based convolution families. The authors note that adding more specialized algorithms (like strided-Winograd or frequency-domain methods) could further improve results.
  • Batch Size: The focus of this paper is on low-latency, single-image inference (batch size = 1). While this is critical for real-time applications like robotics, different optimizations might be needed for high-throughput data center workloads.
  • Quantization: The current implementation uses 8-bit fixed-point math. Exploring how dynamic mapping interacts with mixed-precision quantization (where different layers use different bit-widths) is a promising future direction.

Summary updated

BibTeX
@inproceedings{meng2021dynamap,
  author = {Yuan Meng and Sanmukh R. Kuppannagari and Rajgopal Kannan and Viktor K. Prasanna},
  title = {{DYNAMAP: Dynamic Algorithm Mapping Framework for Low Latency CNN Inference}},
  booktitle = {FPGA},
  year = {2021},
  url = {https://openreview.net/forum?id=9dFfIFehFyT},
}

Loading related content...

Figure