arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2205.09120cs.LG
收藏

ARM CPU上二进制和三进制CNN的快速矩阵乘法

Fast matrix multiplication for binary and ternary CNNs on ARM CPU

Moscow Institute of Physics and Technology(莫斯科物理技术学院);Federal Research Center “Computer Science and Control” of Russian Academy of Sciences(俄罗斯科学院计算机科学与控制联邦研究中心);Smart Engines Service LLC(Smart Engines服务有限责任公司);Institute for Information Transmission Problems, RAS(俄罗斯科学院信息传输问题研究所)

Anton Trusov, Elena Limonova, Dmitry Nikolaev, Vladimir V. Arlazarov

摘要:

低比特量化神经网络在实际应用中有很大的兴趣,因为它们显著地减少了存储器和计算资源的消耗。二进制神经网络是存储器和计算高效的,因为它们每个权重和激活仅需要一位,并且可以使用布尔逻辑和位计数操作来计算。具有三进制权重和激活以及二进制权重和三进制激活的QNN旨在与BNN相比提高识别质量,同时保持低位宽。然而,它们的有效实现通常被认为是在ASIC和FPGA上,限制了它们在实际任务中的适用性。与此同时,最需要高效识别的领域之一是使用CPU的移动设备上的识别。然而,目前还没有已知的TBN和TNN的快速实现,只有用于BNN推理的daBNN库。在本文中,我们提出了新的快速算法的三进制,三进制二进制和二进制矩阵乘法与ARM架构的移动设备。在我们的算法中,三进制权重使用2位编码表示,二进制使用一位。它允许我们用布尔逻辑运算代替矩阵乘法,可以使用ARM NEON SIMD扩展在128位上同时计算。矩阵乘法结果在16位整数寄存器中累加。我们还使用左矩阵和右矩阵中的值的特殊重新排序。所有这些都使我们能够有效地计算矩阵乘积,同时与daBNN算法相比,最小化加载和存储的数量。我们的算法可用于实现TNN、TBN和BNN的卷积层和全连接层的推理。我们在ARM Cortex-A73 CPU上进行了实验评估,并将其推理速度与全精度,8位和4位量化矩阵乘法的有效实现进行了比较。

英文摘要:

Low-bit quantized neural networks are of great interest in practical applications because they significantly reduce the consumption of both memory and computational resources. Binary neural networks are memory and computationally efficient as they require only one bit per weight and activation and can be computed using Boolean logic and bit count operations. QNNs with ternary weights and activations and binary weights and ternary activations aim to improve recognition quality compared to BNNs while preserving low bit-width. However, their efficient implementation is usually considered on ASICs and FPGAs, limiting their applicability in real-life tasks. At the same time, one of the areas where efficient recognition is most in demand is recognition on mobile devices using their CPUs. However, there are no known fast implementations of TBNs and TNN, only the daBNN library for BNNs inference. In this paper, we propose novel fast algorithms of ternary, ternary-binary, and binary matrix multiplication for mobile devices with ARM architecture. In our algorithms, ternary weights are represented using 2-bit encoding and binary - using one bit. It allows us to replace matrix multiplication with Boolean logic operations that can be computed on 128-bits simultaneously, using ARM NEON SIMD extension. The matrix multiplication results are accumulated in 16-bit integer registers. We also use special reordering of values in left and right matrices. All that allows us to efficiently compute a matrix product while minimizing the number of loads and stores compared to the algorithm from daBNN. Our algorithms can be used to implement inference of convolutional and fully connected layers of TNNs, TBNs, and BNNs. We evaluate them experimentally on ARM Cortex-A73 CPU and compare their inference speed to efficient implementations of full-precision, 8-bit, and 4-bit quantized matrix multiplications.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑