TL;DR
The authors introduce CONVGEMM, a method that integrates the im2col transformation directly into the packing routines of the BLIS matrix multiplication framework. This approach eliminates the need for massive intermediate memory workspaces and hides the computational overhead of data rearrangement, matching the performance of highly optimized GEMM kernels on ARM-based multicore processors.
Introduction
In deep learning, the convolutional (CONV) layer is the primary computational heavy lifter. To optimize these layers, engineers typically use the im2col (image-to-column) transformation. This process rearranges input data into a large matrix so that the convolution can be calculated using a General Matrix Multiplication (GEMM) kernel. By integrating this transformation directly into the heart of a high-performance linear algebra library, the authors achieve "the best of both worlds"—speed and memory efficiency.
While GEMM is highly optimized in linear algebra libraries, the standard im2col approach has two major flaws:
- The Memory Wall: The intermediate matrix created by
im2colis often much larger than the original input (e.g., 9x larger for a 3x3 filter). For complex networks like VGG16, this can exceed the RAM of embedded devices. - The Transformation Tax: Rearranging data takes time. As GEMM kernels become faster, the time spent on
im2colbecomes a significant overhead that limits total performance.
Methodology
The researchers leveraged BLIS (Basic Linear Algebra Instantiation Software), a framework known for its portable, high-performance implementation of GEMM. Standard BLIS GEMM works by breaking large matrices into smaller "panels" and "blocks" that fit into specific levels of CPU cache (L1, L2, and L3). Before computation, BLIS uses packing routines to copy data into these buffers in a specific memory layout.
The Innovation: Instead of performing an explicit im2col transformation before calling GEMM, the authors modified the BLIS packing routines to perform the transformation on-the-fly.
- As the library pulls data from the input tensor to fill its internal cache buffers, it calculates exactly where each element should go to satisfy the convolution logic.
- This "smart packing" effectively hides the
im2colcost within the data movement that was already going to happen. - Because the transformation happens directly into the small, pre-existing BLIS buffers, the massive intermediate "augmented matrix" is never actually created in memory.
Experimental Setup
The paper evaluates the algorithm using the architectural specifications of three landmark CNN models: AlexNet, VGG16, and ResNet50. The evaluation was performed on an NVIDIA Jetson TX2 platform, specifically utilizing its quad-core ARM Cortex-A57 CPU.
Key Results and Insights
- Performance Parity: The CONVGEMM routine achieved nearly the same GFLOPS as a standalone, "pure" GEMM. It effectively made the convolution overhead invisible.
- Memory Savings: For VGG16 with a batch size of 80, the standard
im2colapproach requires an additional 8.8 GB of workspace—more than the total RAM available on the Jetson TX2. CONVGEMM ran this same workload with zero additional workspace. - Efficiency: On 4 cores, CONVGEMM significantly outperformed the "Explicit im2col + GEMM" baseline across all models. For VGG16, the baseline performance plummeted due to memory thrashing, while CONVGEMM remained stable and fast.
- Portability: A key feature of BLIS is that only a tiny "micro-kernel" needs to be written in assembly. The authors' changes were made in the high-level C code of the packing routines, meaning this optimization can be easily ported to any architecture BLIS supports (Intel, AMD, ARM, etc.).
Conclusion
CONVGEMM demonstrates a zero-cost transformation approach for convolutions by embedding logic into the packing stage of a GEMM library. This allows devices with limited RAM to run large batch sizes that would otherwise be impossible. While the focus is currently on inference and CPU-centric workloads, future work could explore applying these techniques to the backward pass and low-precision arithmetic to further boost speed on mobile hardware.
Summary updated