TAB: Unified and Optimized Ternary, Binary, and Mixed-precision Neural Network Inference on the Edge
Open Access
- 30 September 2022
- journal article
- research article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Embedded Computing Systems
- Vol. 21 (5) , 1-26
Abstract
Ternary Neural Networks (TNNs) and mixed-precision Ternary Binary Networks (TBNs) have demonstrated higher accuracy compared to Binary Neural Networks (BNNs) while providing fast, low-power, and memory-efficient inference. Related works have improved the accuracy of TNNs and TBNs, but overlooked their optimizations on CPU and GPU platforms. First, there is no unified encoding for the binary and ternary values in TNNs and TBNs. Second, existing works store the 2-bit quantized data sequentially in 32/64-bit integers, resulting in bit-extraction overhead. Last, adopting standard 2-bit multiplications for ternary values leads to a complex computation pipeline, and efficient mixed-precision multiplication between ternary and binary values is unavailable. In this article, we propose TAB as a unified and optimized inference method for ternary, binary, and mixed-precision neural networks. TAB includes unified value representation, efficient data storage scheme and novel bitwise dot product pipelines on CPU/GPU platforms. We adopt signed integers for consistent value representation across binary and ternary values. We introduce a bitwidth-last data format that stores the first and second bits of the ternary values separately to remove the bit extraction overhead. We design the ternary and binary bitwise dot product pipelines based on Gated-XOR using up to 40% fewer operations than State-Of-The-Art (SOTA) methods. Theoretical speedup analysis shows that our proposed TAB-TNN is 2.3× fast as the SOTA ternary method RTN, 9.8× fast as 8-bit integer quantization (INT8), and 39.4× fast as 32-bit full-precision convolution (FP32). Experiment results on CPU and GPU platforms show that our TAB-TNN has achieved up to 34.6× speedup and 16× storage size reduction compared with FP32 layers. TBN, Binary-activation Ternary-weight Network (BTN), and BNN in TAB are up to 40.7×, 56.2×, and 72.2× as fast as FP32. TAB-TNN is up to 70.1% faster and 12.8% more power-efficient than RTN on Darknet-19 while keeping the same accuracy. TAB is open source as a PyTorch Extension 1 for easy integration with existing CNN models.Keywords
Funding Information
- Ministry of Education, Singapore (MOE2019-T2-1-071, and MOE2019-T1-001-072)
- Nanyang Technological University, Singapore (NAP (M4082282), and SUG (M4082087))
This publication has 27 references indexed in Scilit:
- TBN: Convolutional Neural Network with Ternary Inputs and Binary Weights2018
- Bi-Real Net: Enhancing the Performance of 1-Bit CNNs with Improved Representational Capability and Advanced Training Algorithm2018
- LQ-Nets: Learned Quantization for Highly Accurate and Compact Deep Neural Networks2018
- GXNOR-Net: Training deep neural networks with ternary weights and activations without full-precision memory under a unified discretization frameworkNeural Networks, 2018
- BMXNet2017
- Ternary neural networks for resource-efficient AI applications2017
- XNOR-Net: ImageNet Classification Using Binary Convolutional Neural Networks2016
- Performance, Design, and Autotuning of Batched GEMM for GPUs2016
- A Note on Auto-tuning GEMM for GPUs2009
- GEMM-based level 3 BLASACM Transactions on Mathematical Software, 1998