Skip to content
Enabling Flexible FPGA High-Level Synthesis of Tensorflow Deep Neural Networks
Branch: master
Clone or download
santacml and danielholanda Added support for reduce operation (#14)
* Change ir_emitter and llvm_loop to support reduce_ops. Updated readme and added new tensorflow.

* Delete accidental file
Latest commit 1f1ec0a Feb 4, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Added new demo video Oct 24, 2018
img Added new demo Nov 20, 2018
src Added support for reduce operation (#14) Feb 4, 2019
test Removed matplotlib to fix issue #2 Aug 15, 2018 Updated README file Jan 3, 2019


LeFLow is an open-source tool-flow that maps numerical computation models written in Tensorflow to synthesizable hardware. Our flow bridges Google's XLA compiler LegUp high-level synthesis tool to automatically generate verilog from a Tensorflow specification.

See publication here:

Demo Videos

Demo 1 - Overview

Demo 2 - DNN for Classifying Google's Quick Draw Dataset

Installing dependencies


LeFlow was built to be compatible with LegUp 4.0. We recommend downloading the virtual machine available at


LeFlow makes some minor changes on Tensorflow to ensure that only Kernels supported by LegUp are used by Tensorflow's XLA. To install the modified version of Tensorflow in the Legup 4.0 virtual machine follow the instructions below.

sudo apt-get install python-pip
sudo python -m pip install --upgrade pip
sudo pip install tensorflow-1.6.0-cp27-cp27mu-linux_x86_64.whl --ignore-installed six

The whl file and instruction for compiling Tensorflow from scratch can be found on the src/tensorflow folder.

LeFlow settings

Before running LeFlow for the first time go to src\LeFlow and set up your python path and the examples directory of Legup. It is also important to make the LeFlow file an executable using the command

chmod +x LeFlow

Testing your installation

LeFlow comes to 15 building blocks that are contained inside of the tests folder and used for testing. You should try those tests first before jumping to the more complex examples. The automated testing will generate circuit, test it with Modelsim and make sure that the results match the original Tensorflow results.

  • To test your installation, go into the test directory and run
    python --fast

All the tests should take less than a minute. For a more complete test, just run the same python script without the "--fast" option.

If one of the tests fail you have a problem with your installation. Please also make sure that the code works with Tesorflow before trying to generate a circuit using LeFlow.

Getting Started

Running a single example

To begin running examples with LeFlow tool, do the following:

  • Enter the ./test directory and select an example directory (i.e. myAdd)
  • To generate hardware from Tensorflow implementation run
  • To test generated hardware using Modelsim run
    ../../src/LeFlow --modelsim_only  
  • To do both above actions with a single command, run
    ../../src/LeFlow --modelsim 


  • src -- includes source code for LeFlow
  • test -- simple examples that be run to test the tool
  • examples -- complicated examples that can take a significant amount of time to run


  • Daniel Holanda Noronha -
  • Bahar Salehpour
  • Steve Wilton

Citing LeFlow

Please cite LeFlow in your publications if it helps your research work:

     author = {{Noronha}, D.~H. and {Salehpour}, B. and {Wilton}, S.~J.~E.},
     title = "{LeFlow: Enabling Flexible FPGA High-Level Synthesis of Tensorflow Deep Neural Networks}",
     journal = {ArXiv e-prints},
     archivePrefix = "arXiv",
     eprint = {1807.05317},
     keywords = {Computer Science - Machine Learning, Statistics - Machine Learning},
     year = 2018,
     month = jul,
     adsurl = {}


This project is licensed under the MIT License - see the file for details

You can’t perform that action at this time.