Im2win:SIMD架构上的内存高效卷积
Im2win: Memory Efficient Convolution On SIMD Architectures
AI总结:
提出内存高效数据转换算法im2win及基于其的高性能卷积算法,通过重构窗口实现连续内存访问,平均减少41.6%内存开销并实现最高5.3倍加速。
摘要:
卷积是神经网络操作中开销最大的运算,因此其性能对神经网络的整体性能至关重要。常用的卷积方法,包括基于通用矩阵乘法(GEMM)的卷积和直接卷积,分别依赖im2col进行数据转换或完全不使用数据转换。然而,与完全不使用数据转换相比,im2col数据转换会导致至少2倍的内存占用,从而限制了在内存受限系统上运行的神经网络模型的大小。同时,尽管不使用数据转换消耗的内存较少,但由于非连续内存访问,其性能通常较差。为了解决这些问题,我们提出了一种新的内存高效数据转换算法,称为im2win。该算法重构输入图像的方形或矩形点积窗口行,并将这些窗口内的唯一元素展平为输出张量中的一行,从而实现连续内存访问和数据重用,大大减少了内存开销。此外,我们提出了一种基于im2win的高性能卷积算法,包含多种优化,如向量化、循环重排序等。实验结果表明,与PyTorch基于im2col的卷积实现相比,我们的算法平均减少了41.6%的内存开销,并且与基于im2col的卷积和不使用数据转换相比,分别实现了平均3.6倍和5.3倍的性能加速。
英文摘要:
Convolution is the most expensive operation among neural network operations, thus its performance is critical to the overall performance of neural networks. Commonly used convolution approaches, including general matrix multiplication (GEMM)-based convolution and direct convolution, rely on im2col for data transformation or do not use data transformation at all, respectively. However, the im2col data transformation can lead to at least 2$\times$ memory footprint compared to not using data transformation at all, thus limiting the size of neural network models running on memory-limited systems. Meanwhile, not using data transformation usually performs poorly due to nonconsecutive memory access although it consumes less memory. To solve those problems, we propose a new memory-efficient data transformation algorithm, called im2win. This algorithm refactorizes a row of square or rectangle dot product windows of the input image and flattens unique elements within these windows into a row in the output tensor, which enables consecutive memory access and data reuse, and thus greatly reduces the memory overhead. Furthermore, we propose a high-performance im2win-based convolution algorithm with various optimizations, including vectorization, loop reordering, etc. Our experimental results show that our algorithm reduces the memory overhead by average to 41.6% compared to the PyTorch's convolution implementation based on im2col, and achieves average to 3.6$\times$ and 5.3$\times$ speedup in performance compared to the im2col-based convolution and not using data transformation, respectively.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。