Skip to content

This is a BNN_Kernel on PyTorch for 1-bit networks in image data processing

Notifications You must be signed in to change notification settings

canesin/BNN_Kernel

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Description

In theory, Binarized Neural Networks boast of x32 compression and x10 acceleration on GPUs. However, all variables are stored and manipulated in the form of float-32 on PyTorch. In this case, if we want to implement 1-bit networks on PyTorch, we have to change the kernel.

This repository contains a wrapped CUDA kernel that supports both 1-bit storage and computation on PyTorch

How to use

check the environment

GCC:     >=5.0
PyTorch: <1.0
PyThon:  >=3.5
CUDA:    >=8.0

build the kernel

GPU

cd ./csrc/binop
make

CPU

cd ./csrc/binop_cpu
make

check the API and use

GPU

import torch
import binop
...

CPU

import torch
import binop_cpu

References

How to wrap a CUDA and use its functions in PyTorch:

Pytorch Custom CUDA kernel Tutorial

Examples

You can see the GPU example in test

You can see the CPU example in test

About

This is a BNN_Kernel on PyTorch for 1-bit networks in image data processing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 33.8%
  • C++ 33.2%
  • Python 23.4%
  • Cuda 7.8%
  • Makefile 1.5%
  • Shell 0.3%