[Paper Review] Low-memory GEMM-based convolution algorithms for deep neural networks
This paper proposes two novel GEMM-based convolution algorithms for deep neural networks that drastically reduce memory overhead by restructuring convolutions as accumulations of smaller 1×1 convolutions. The methods require only O(MHW) and O(KW) additional memory—significantly less than the O(CHWK²) of standard im2col or O(CHWK) of prior GEMM-based approaches—while achieving comparable or better performance, especially on multi-core systems due to superior data locality.
Deep neural networks (DNNs) require very large amounts of computation both for training and for inference when deployed in the field. A common approach to implementing DNNs is to recast the most computationally expensive operations as general matrix multiplication (GEMM). However, as we demonstrate in this paper, there are a great many different ways to express DNN convolution operations using GEMM. Although different approaches all perform the same number of operations, the size of temporary data structures differs significantly. Convolution of an input matrix with dimensions $C imes H imes W$, requires $O(K^2CHW)$ additional space using the classical im2col approach. More recently memory-efficient approaches requiring just $O(KCHW)$ auxiliary space have been proposed. We present two novel GEMM-based algorithms that require just $O(MHW)$ and $O(KW)$ additional space respectively, where $M$ is the number of channels in the result of the convolution. These algorithms dramatically reduce the space overhead of DNN convolution, making it much more suitable for memory-limited embedded systems. Experimental evaluation shows that our low-memory algorithms are just as fast as the best patch-building approaches despite requiring just a fraction of the amount of additional memory. Our low-memory algorithms have excellent data locality which gives them a further edge over patch-building algorithms when multiple cores are used. As a result, our low memory algorithms often outperform the best patch-building algorithms using multiple threads.
Motivation & Objective
- To address the high memory overhead of existing GEMM-based DNN convolution methods, particularly the O(CHWK²) space required by the widely used im2col approach.
- To design memory-efficient GEMM-based convolution algorithms suitable for embedded and memory-constrained systems.
- To explore the trade-offs between memory usage, computation, and data locality in GEMM-based DNN convolution implementations.
- To evaluate whether low-memory GEMM-based algorithms can match or exceed the performance of high-memory patch-building approaches, especially under multi-threaded execution.
Proposed method
- Reformulate multi-channel multi-kernel (MCMK) convolution as an accumulation of K² separate 1×1 convolutions, each processed via GEMM.
- Use a tiling strategy to process small, manageable blocks of the input and kernel tensors, reducing temporary storage needs.
- Apply data layout transformations that allow GEMM calls to operate on compact, localized data structures instead of full im2col matrices.
- Optimize memory access patterns to improve cache locality and reduce L1/L3 cache stall cycles, especially under multi-core execution.
- Implement two variants: one using row-major layout for MHW-sized accumulations (O(MHW) space), and another using column-major layout for KW-sized accumulations (O(KW) space).
- Leverage existing, highly optimized BLAS/GEMM libraries to maintain high computational performance while minimizing custom kernel development.
Experimental results
Research questions
- RQ1Can GEMM-based convolution be implemented with significantly reduced temporary memory usage while maintaining high performance?
- RQ2How does reducing memory footprint affect data locality and multi-core performance in DNN convolution?
- RQ3Can low-memory GEMM-based algorithms outperform traditional patch-building approaches in terms of speed and efficiency on multi-core architectures?
- RQ4What are the optimal data layout and tiling strategies for minimizing memory usage in GEMM-based MCMK convolution?
- RQ5How do the memory and performance characteristics of the proposed algorithms compare to existing approaches like im2col and lazy im2col across different hardware platforms?
Key findings
- The proposed O(MHW) and O(KW) memory algorithms achieve performance comparable to the best patch-building GEMM-based methods, despite using orders of magnitude less temporary memory.
- On Intel Core i7 and ARM Cortex A57 processors, the low-memory algorithms showed fewer L1 and L3 cache stall cycles than competing methods, with kn2row-aa achieving the lowest average stall count.
- In multi-core environments, the improved data locality of the low-memory algorithms led to better performance than patch-building methods, often outperforming them due to reduced memory bandwidth pressure.
- The O(KW) variant demonstrated particularly strong performance on upper layers of VGG16, where it outperformed even the best-performing alternative in terms of cache efficiency.
- The experimental results confirm that memory reduction does not come at the cost of speed, and that memory efficiency can be a key enabler for high-performance inference on embedded systems.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.