XNOR extension
In XNOR convolution, both the filters and the input to convolutional layers are binary. Now, by approximating the convolution operations with XNOR and bitcounting operations, we can gain massive speed-up and memory savings.
xnor convolution using bitwise operation
Implement on numpy-python, Cpp and CUDA.
- Inspect the C++ and CUDA extensions in the
cpp/
andcuda/
folders,
Build C++ and/or CUDA extensions by going into the cpp/
or cuda/
folder and executing python setup.py install
,
cd cpp
python setup.py install
cd cuda
python setup.py install
import binary_cpp
output = binary_cpp.binary_conv2d(input,filter,bias)
import binary_cuda
output = binary_cuda.binary_conv2d_cuda(input,filter,bias)
from py.xnor_bitwise_numpy import xnor_bitwise_np
out = xnor_bitwise_np(input,filter)
[1] https://github.com/pytorch/extension-cpp
[2] Rastegari, Mohammad, Vicente Ordonez, Joseph Redmon, and Ali Farhadi. "Xnor-net: Imagenet classification using binary convolutional neural networks." In European conference on computer vision, pp. 525-542. Springer, Cham, 2016.
[3] https://github.com/cooooorn/Pytorch-XNOR-Net