Skip to main content
QUICK REVIEW

[论文解读] Characterizing and Demystifying the Implicit Convolution Algorithm on Commercial Matrix-Multiplication Accelerators

Yangjie Zhou, Mengtian Yang|arXiv (Cornell University)|Oct 8, 2021
Parallel Computing and Optimization Techniques被引用 5
一句话总结

本文提出了一种内存高效、硬件友好的隐式 im2col 算法,可在基于 GEMM 的加速器(如 Google 的 TPU 和 NVIDIA 的 Tensor Cores)上以接近零的性能和内存开销,动态地将卷积映射到 GEMM。通过利用卷积的结合律和交换律,并优化内存布局与分块策略,该方法实现了片外内存访问与计算的完全重叠,性能达到或优于专有的实现方案。

ABSTRACT

Many of today's deep neural network accelerators, e.g., Google's TPU and NVIDIA's tensor core, are built around accelerating the general matrix multiplication (i.e., GEMM). However, supporting convolution on GEMM-based accelerators is not trivial. The naive method explicitly lowers the convolution to GEMM, commonly known as im2col, which introduces significant performance and memory overhead. Existing implicit im2col algorithms require unscalable hardware and are inefficient in supporting important convolution variants such as strided convolution. In this paper, we propose a memory-efficient and hardware-friendly implicit im2col algorithm used by Google's TPU, which dynamically converts a convolution into a GEMM with practically zero performance and memory overhead, fully unleashing the power of GEMM engines. Through comprehensive experimental results, we quantitatively argue that this algorithm has been adopted in commercial closed-source platforms, and we are the first to describe its high-level idea and implementation details. Finally, we show that our algorithm can also be generally applied to Nvidia's Tensor Cores (TC), matching and out-performing the measured performance on TCs.

研究动机与目标

  • 解决在基于 GEMM 的深度神经网络加速器(如 TPU 和 GPU)中,显式 im2col 所带来的高内存与性能开销问题。
  • 逆向工程并描述首个公开可用的、用于商业加速器的硬件友好型隐式 im2col 算法实现。
  • 证明所提出的隐式 im2col 方法可实现接近零开销,并在 TPU 和 NVIDIA Tensor Cores 上达到或超越专有实现的性能表现。
  • 通过开源可配置的 TPU 模拟器和 GPU 实现,推动 DNN 加速领域的更广泛研究与优化。

提出的方法

  • 提出一种以通道为先的隐式 im2col 算法,利用卷积的结合律与交换律,避免显式的数据重格式化。
  • 设计一种内存布局与分块策略,使在脉动数组上的片外内存访问可与计算完全重叠。
  • 开发了一个可配置的周期级 TPU 模拟器,经与云 TPUv2 对比,平均误差率低于 5%。
  • 通过分块 im2col 方法与分块重排策略,将算法适配至 NVIDIA Tensor Cores,以最小化全局内存访问导致的停顿。
  • 通过块间数据重用优化,提升片上数据局部性,降低全局内存带宽压力。
  • 在 V100 GPU 上实现该方法,并与 cuDNN 进行性能对比,采用作者无法获取的微优化技术。
Figure 1: Illustration of the im2col algorithm that converts a CONV layer to a GEMM operation. For simplicity, this examples assumes no padding in the IFMap.
Figure 1: Illustration of the im2col algorithm that converts a CONV layer to a GEMM operation. For simplicity, this examples assumes no padding in the IFMap.

实验结果

研究问题

  • RQ1如何在 GEMM 专用加速器(如 TPU 和 Tensor Cores)上,以最小的性能与内存开销,高效地将卷积映射到 GEMM?
  • RQ2哪些架构与算法技术使得隐式 im2col 能够避免显式 im2col 所带来的内存与计算开销?
  • RQ3为何先前工作的隐式 im2col 方法不适用于大规模商业加速器(如 TPU)?
  • RQ4是否可以实现在脉动数组与现代 GPU Tensor Cores 上均具备竞争力的通用、开源隐式 im2col 算法?
  • RQ5内存布局、分块策略与数据重用在实现 GEMM 加速器高性能中起到何种作用?

主要发现

  • 所提出的隐式 im2col 方法通过动态映射卷积至 GEMM,无需显式数据转换,实现了接近零的性能与内存开销。
  • 该方法在 TPU 上实现了片外内存访问与计算的完全重叠,减少了空闲时间,最大化了硬件利用率。
  • 在 V100 GPU 上,该实现的性能在批量大小为 8 时与 cuDNN 相差不足 1%,展现出与专有代码相当的竞争力。
  • 对于步长大于 1 的卷积操作,该方法平均快 20%,最快快 40%,凸显其在处理非单位步长操作时的优越性。
  • 块间重用优化在具有高全局内存访问开销的 GPU 工作负载上,平均提升了 16.7% 的性能。
  • 作者开发的 TPUv2 模拟器与真实云 TPUv2 测量结果相比,平均误差率低于 5%,验证了其准确性。
(a) NVIDIA V100 GPU.
(a) NVIDIA V100 GPU.

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。