Abstract
Binary Neural Networks (BNNs) offer a promising path toward deploying sophisticated deep learning models on resource-constrained ARM devices by compressing weights and activations to 1-bit. Despite their theoretical efficiency, a significant "software gap" has prevented existing frameworks from achieving real-world speedups. We introduce daBNN, an open-source, high-performance inference framework specifically optimized for ARM-based mobile and embedded systems. By employing hand-optimized ARM assembly, novel memory layouts, and algorithmic re-ordering to bypass hardware bottlenecks, daBNN achieves up to 23x faster performance than previous BNN frameworks and significantly outperforms full-precision industry standards like TensorFlow Lite.
Introduction
Deep Neural Networks (DNNs) have transformed computer vision but remain computationally prohibitive for low-end ARM devices such as smartphones. BNNs address this by replacing heavy floating-point arithmetic with fast bitwise operations (XNOR and Popcount). However, many existing BNN implementations are surprisingly slow, sometimes performing worse than highly optimized full-precision frameworks. daBNN was developed to bridge this gap, delivering a framework that finally realizes the speed promises of binary quantization on mobile hardware.
Optimization Methods
To maximize performance on ARM architectures, daBNN implements several low-level optimizations:
Upgraded Bit-packing
Instead of sequential bit comparison, daBNN extracts sign bits directly from 32-bit integers or floats. Using SIMD "right-shift-and-overwrite" instructions, it packs multiple sign bits into a single vector simultaneously, achieving a 4x speedup over naive packing methods.
Binary Direct Convolution
Standard binary matrix multiplication (BGEMM) relies on the cnt (count set bits) and addv (sum vector elements) instructions. On ARM, addv is a known performance bottleneck. daBNN mathematically re-arranges the calculation order to sum the results of cnt within registers before calling addv, drastically reducing the total instruction count and latency.
$NC_1HWC_2$ Memory Layout
Memory access is often more expensive than computation in mobile environments. daBNN introduces a custom $NC_1HWC_2$ memory layout where $C_2$ matches the 128-bit length of an ARM register. This layout facilitates maximum register reuse; for a 3x3 convolution, this strategy eliminates approximately two-thirds of the required memory loading operations.
Architectural Refinement: The STEM Module
The first layer of a network often remains in full precision to preserve accuracy, but it can account for over 50% of total latency. daBNN addresses this by replacing large initial convolutions (e.g., 7x7) with a "STEM" module—a sequence of smaller, faster convolutions—yielding a 30% total speedup with negligible accuracy loss.
Key Results
Evaluated on a Google Pixel 1 using the Bi-Real Net 18 architecture on ImageNet, daBNN demonstrated substantial gains:
- Performance vs. BNN Frameworks: daBNN is 7x to 23x faster than BMXNet on single binary convolutions and 6x faster on full models.
- Performance vs. Full Precision: Compared to TensorFlow Lite, daBNN is 8x to 10x faster on single convolutions and 3x faster on the full Bi-Real Net 18 model.
- Efficiency: Models are compressed by approximately 32x, and the framework maintains interoperability via an
onnx2bnnconversion tool.
Conclusion
daBNN provides a significant leap forward for BNN inference on ARM devices. By identifying and resolving low-level hardware bottlenecks like the addv instruction and optimizing memory access patterns, it enables high-speed deep learning on edge devices. Future work will focus on expanding support to X86 and RISC-V architectures and increasing the coverage of optimized layer types.
The source code is available at: https://github.com/JDAI-CV/dabnn
Summary updated