• Stars
    star
    297
  • Rank 140,075 (Top 3 %)
  • Language
    C
  • License
    BSD 3-Clause "New...
  • Created almost 8 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Binarized Convolutional Neural Networks on Software-Programmable FPGAs

Publications

If you use this code in your research, please cite our FPGA'17 paper:

  @article{zhao-bnn-fpga2017,
    title   = "{Accelerating Binarized Convolutional Neural Networks
              with Software-Programmable FPGAs}",
    author  = {Ritchie Zhao and Weinan Song and Wentao Zhang and Tianwei Xing and
               Jeng-Hau Lin and Mani Srivastava and Rajesh Gupta and Zhiru Zhang},
    journal = {Int'l Symp. on Field-Programmable Gate Arrays (FPGA)},
    month   = {Feb},
    year    = {2017},
  }

Introduction

bnn-fpga is an open-source implementation of a binarized neural network (BNN) accelerator for CIFAR-10 on FPGA. The architecture and training of the BNN is proposed by Courbarieaux et al. and open-source Python code is available at https://github.com/MatthieuCourbariaux/BinaryNet.

Our accelerator targets low-power embedded field-programmable SoCs and was tested on a Zedboard. At time of writing the error rate on the 10000 images in the CIFAR-10 test set is 11.19%.

Build Setup

You will need Xilinx SDSoC on your PATH and the Vivado HLS header include files on your CPATH.

Verified SDSoC versions: 2016.4, 2017.1

With these tools in place do the following from the repository root:

  % source setup.sh
  % cd data; ./get_data.sh; cd ..
  % cd params; ./get_params.sh; cd ..

This will set environment variables and download data and parameter zip files.

If the get scripts do not work, please go to this Google Drive to download the files that need to go into the data and params folders.

To build the software model:

  % cd cpp
  % make -j4

To build the FPGA bitstream do (with the software build complete):

  % cd cpp/accel/sdsoc_build
  % make -j4

Post-route timing and area information is available in sdsoc_build/_sds/reports/sds.rpt.

Branches

The master branch contains a debug build including a random testbench, a per-layer testbench, and a full bnn testbench. The optimized branch contains only the full testbench.

FPGA Evaluation

  1. After the FPGA bitstream is finished building, copy the sd_card directory onto an SD card.
  2. Copy both data and params directories onto the same SD card.
  3. Insert the card into the Zedboard and power on the Zedboard.
  4. Connect to the Zedboard via USB and wait for the boot sequence to finish.
  5. At the terminal prompt do the following:
  % cd mnt
  % export CRAFT_BNN_ROOT=.
  % ./accel_test_bnn.exe <N>

Where N is the number of images you want to test. Up to 10000 images from the CIFAR-10 test set are available. The program will print out the prediction accuracy and accelerator runtime at the end. Note that the program performs weight binarization and reordering before invoking the accelerator so there will be a pause at the very beginning.

Varying the Number of Convolvers

Go to cpp/accel/Accel.h and change CONVOLVERS to the desired number (must be a power of 2). You must do a make clean and rebuild everything from scratch.

Known Issues and Bugs

  1. SDSoC compilation error due to glibc include file (Issue #1)
    This occurs if SDSoC sees the native version of glibc on CPATH, overriding the ARM version for cross-compilation. The fix is to remove /usr/include from CPATH. In some cases this prevents SDSoC from seeing zlib; currently the suggested fix is to build zlib in a different (non-system) directory and add that to CPATH.

More Repositories

1

heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
Python
322
star
2

rosetta

Rosetta: A Realistic High-level Synthesis Benchmark Suite for Software Programmable FPGAs
C++
156
star
3

allo

Allo: A Programming Model for Composable Accelerator Design
Python
130
star
4

GraphZoom

GraphZoom: A Multi-level Spectral Approach for Accurate and Scalable Graph Embedding
Python
112
star
5

dnn-quant-ocs

DNN quantization with outlier channel splitting
Python
109
star
6

FracBNN

FracBNN: Accurate and FPGA-Efficient Binary Neural Networks with Fractional Activations
Python
87
star
7

HiSparse

High-Performance Sparse Linear Algebra on HBM-Equipped FPGAs Using HLS
C++
79
star
8

dnn-gating

Conditional channel- and precision-pruning on neural networks
Python
72
star
9

GraphLily

A graph linear algebra overlay
C++
48
star
10

facedetect-fpga

C++
43
star
11

hcl-dialect

HeteroCL-MLIR dialect for accelerator design
C++
40
star
12

GARNET

GARNET: Reduced-Rank Topology Learning for Robust and Scalable Graph Neural Networks
Python
33
star
13

UniSparse

Code base for OOPSLA'24 paper: UniSparse: An Intermediate Language for General Sparse Format Customization
MLIR
28
star
14

Polynormer

Polynormer: Polynomial-Expressive Graph Transformer in Linear Time
Python
28
star
15

quickest

QuickEst repository: Quick Estimation of Quality of Results
Python
26
star
16

uptune

A Generic Distributed Auto-Tuning Infrastructure
Python
21
star
17

HOGA

Hop-Wise Graph Attention for Scalable and Generalizable Learning on Circuits
Python
21
star
18

llm-datatypes

Codebase for ICML'24 paper: Learning from Students: Applying t-Distributions to Explore Accurate and Efficient Formats for LLMs
Python
18
star
19

datuner

DATuner Repository
LLVM
17
star
20

allo-pldi24-artifact

Artifact evaluation of PLDI'24 paper "Allo: A Programming Model for Composable Accelerator Design"
VHDL
14
star
21

GLAIVE

Graph-learning assisted instruction vulnerability estimation published in DATE 2020
C++
13
star
22

tutorial-fccm21

HTML
6
star
23

catalyst2018

Python
3
star