Introduction
Convolutions serve as the computational foundation for modern artificial intelligence. However, high-performance hardware—such as Google’s Tensor Processing Units (TPUs) and NVIDIA’s Tensor Cores—is primarily architected for General Matrix Multiplication (GEMM). To bridge this gap, convolutions are typically transformed into GEMM operations using a process known as im2col.
While the "explicit" version of this transformation involves physically copying and expanding data, leading to significant memory and performance overheads, commercial vendors employ "implicit" versions that bypass these costs. This paper demystifies these proprietary algorithms and introduces a "channel-first" implicit im2col approach that optimizes data fetching and eliminates memory bloat.
The Im2col Bottleneck
The standard approach to executing convolutions on matrix-centric hardware involves rearranging input feature maps (IFmaps) into a large intermediate matrix. In an explicit im2col implementation, the input data is duplicated to form this matrix, often increasing memory requirements by 1.5x to 10x.
As illustrated above, the transformation maps spatial and channel dimensions into a format suitable for systolic arrays or GPU cores. However, the data movement required for explicit transformation introduces a performance penalty averaging 26%. Furthermore, existing academic models for implicit convolution often fail to scale or struggle with "strided" convolutions, where hardware utilization can drop by up to 60%.
Proposed Methodology: Channel-First Implicit Im2col
The authors propose a Channel-First Implicit Im2col algorithm designed for scalability and efficiency:
- Channel-First Layout: By organizing the input feature map in memory such that the channel dimension is unrolled first (HWC format), the hardware can read data as a single "wide word." This simplifies memory architecture, replacing expensive crossbars with simple, single-banked memory.
- Systolic Array Mapping: On TPU-like architectures, the algorithm uses independent SRAM arrays for each row of the processing engine. By "skewing" address generation, data is fed into the GEMM engine in a time-delayed fashion that aligns with the hardware's natural systolic flow.
- Blocked GPU Implementation: For NVIDIA Tensor Cores, a blocked version partitions the output matrix to prevent "atomic updates," ensuring multiple threads do not conflict when writing to memory.
- Validation via TPUSim: To verify these architectural insights, the researchers developed
TPUSim, a cycle-accurate simulator validated against real-world Google Cloud TPUv2 measurements.
Key Results and Performance
The proposed implicit algorithm achieves near-zero memory overhead and matches the performance of raw GEMM operations. Validation against commercial hardware shows that the "demystified" model is highly accurate.
As shown in the performance characterization on the Google TPU-v2, the implicit method consistently outperforms explicit implementations by eliminating the im2col transformation time (the blue segments in the chart). Other notable results include:
- Simulator Accuracy:
TPUSimachieved an average error rate of less than 5% compared to actual Cloud TPUv2 hardware. - GPU Efficiency: On an NVIDIA V100, the implementation performed within 1% of NVIDIA’s proprietary cuDNN library.
- Strided Convolution Superiority: For strided operations, the proposed method was 20% to 40% faster than cuDNN by decomposing filters into 1x1 convolutions to maintain high hardware utilization.
Conclusion and Future Directions
This work provides a transparent look into the high-performance convolution algorithms used in industry. By adopting a channel-first layout and optimized hardware mapping, the authors demonstrate that it is possible to achieve vendor-level performance (or better) without proprietary secrets.
Future research will focus on optimizing filter execution reordering for better data reuse and exploring how implicit im2col interacts with emerging sparse accelerators, which skip zero-valued entries to save energy.
Summary updated