Skip to content

Commit

Permalink
Merge pull request #760 from Xilinx/dev
Browse files Browse the repository at this point in the history
Release Merge for v0.9
  • Loading branch information
auphelia committed Feb 10, 2023
2 parents 41740ed + 17af0c3 commit cdc5ec4
Show file tree
Hide file tree
Showing 178 changed files with 10,403 additions and 1,645 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
name: DockerImage

on:
pull_request:
branches: [ dev ]
push:
branches:
- 'dev'
branches: [ dev ]

jobs:
docker:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
-
name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'

- name: Run Lint
uses: pre-commit/action@v2.0.0
uses: pre-commit/action@v3.0.0
40 changes: 6 additions & 34 deletions .github/workflows/quicktest-dev-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,43 +11,15 @@ jobs:

test:
name: Run quicktest on PR branch
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04

steps:
- name: checkout
uses: actions/checkout@v2

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push
uses: docker/build-push-action@v2
with:
file: docker/Dockerfile.finn
context: .
push: false
load: true
tags: finn_gha
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
-
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
uses: actions/checkout@v3

- name: DockerRunQuicktest
run: |
docker run --init --hostname finn_gha -w $(pwd) -v $(pwd):$(pwd) -e FINN_BUILD_DIR=/tmp/finn_gha -e FINN_INST_NAME=finn_gha finn_gha quicktest.sh
export FINN_ROOT=$(pwd)
export FINN_BUILD_DIR=/tmp/finn_gha
export FINN_INST_NAME=finn_gha
./run-docker.sh quicktest
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ repos:
args: ['--fix=no']

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort

Expand All @@ -61,7 +61,7 @@ repos:
- id: black
language_version: python3

- repo: https://gitlab.com/pycqa/flake8
- repo: https://github.com/PyCQA/flake8
rev: 3.9.2
hooks:
- id: flake8
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ sphinx:
configuration: docs/finn/conf.py

python:
version: 3.7
version: 3.8
install:
- method: pip
path: .
Expand Down
4 changes: 3 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Contributors
* Hendrik Borras (@HenniOVP)
* Lucian Petrica (@quetric)
* Tobias Alonso (@Tobi-Alonso)
* Felix Paul Jentzsch (@felixpj)
* Felix Paul Jentzsch (@fpjentzsch)
* Mirza Mrahorovic (@mmrahorovic)
* Suranga Mahesh (@surangamh)
* Peter Lehnhardt (@pete-lennart)
Expand All @@ -26,3 +26,5 @@ Contributors
* Aziz Bahri (@azizb-xlnx)
* Fionn O'Donohoe (@fionnodonohoe-xlnx)
* Matthias Gehre (@mgehre-amd)
* Hugo Le Blevec (@hleblevec)
* Patrick Geel (@patrickgeel)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Please see the [Getting Started](https://finn.readthedocs.io/en/latest/getting_s

## Documentation

You can view the documentation on [readthedocs](https://finn.readthedocs.io) or build them locally using `python setup.py doc` from inside the Docker container. Additionally, there is a series of [Jupyter notebook tutorials](https://github.com/Xilinx/finn/tree/master/notebooks), which we recommend running from inside Docker for a better experience.
You can view the documentation on [readthedocs](https://finn.readthedocs.io) or build them locally using `python setup.py doc` from inside the Docker container. Additionally, there is a series of [Jupyter notebook tutorials](https://github.com/Xilinx/finn/tree/main/notebooks), which we recommend running from inside Docker for a better experience.

## Community

Expand Down Expand Up @@ -67,4 +67,4 @@ The current implementation of the framework is based on the following publicatio
## Old version

We previously released an early-stage prototype of a toolflow that took in Caffe-HWGQ binarized network descriptions and produced dataflow architectures. You can find it in the [v0.1](https://github.com/Xilinx/finn/tree/v0.1) branch in this repository.
Please be aware that this version is deprecated and unsupported, and the master branch does not share history with that branch so it should be treated as a separate repository for all purposes.
Please be aware that this version is deprecated and unsupported, and the main branch does not share history with that branch so it should be treated as a separate repository for all purposes.
55 changes: 51 additions & 4 deletions custom_hls/lookup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
*******************************************************************************/
#ifndef LOOKUP_HPP
#define LOOKUP_HPP

#include <ap_int.h>
#include <hls_stream.h>

#ifndef LOOKUP_HPP
#define LOOKUP_HPP
#include "utils.hpp"


template <
unsigned NumEmbeddings,
Expand All @@ -57,4 +58,50 @@ void StreamingLookup(
}
}

/**
* Lookup implementation over a table stored in AXI-accessible memory.
*/
template <
unsigned EmbeddingSize, // Number of memory words per embedding
unsigned EmbeddingAlign = clog2(EmbeddingSize), // Alignment of entries = number of word index bits
typename T_SRC,
typename T_DST
>
void StreamingLookup_ext(
hls::stream<T_SRC> &in0,
hls::stream<T_DST> &out,
T_DST const *const mem,
unsigned const size,
unsigned &oob_count,
bool &oob_irq
) {
#pragma HLS pipeline II=EmbeddingSize+9 style=flp

static unsigned oob_count_li;
static unsigned oob_count_int;
#pragma HLS reset variable=oob_count_li
#pragma HLS reset variable=oob_count_int

if(oob_count != oob_count_li) {
oob_count_int -= oob_count_li;
oob_count_li = oob_count;
}
if(!in0.empty()) {
T_SRC const x = in0.read();

// Map out-of-bounds inputs to an offset of zero and increment counter
bool const oob = x >= T_SRC(size);
ap_uint<T_SRC::width+EmbeddingAlign> const ofs =
((oob? T_SRC(0) : x), ap_uint<EmbeddingAlign>(0));
oob_count_int += oob;

// Stream lookup data (burst inferred)
for(unsigned i = 0; i < EmbeddingSize; i++) {
#pragma HLS pipeline II=1 style=flp
out.write(mem[ofs+i]);
}
}
oob_count = oob_count_int;
oob_irq = (oob_count_int != 0);
}
#endif
13 changes: 11 additions & 2 deletions docker/Dockerfile.finn
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ RUN apt-get update && \
libsm6 \
libxext6 \
libxrender-dev \
verilator \
nano \
zsh \
rsync \
Expand All @@ -62,6 +61,16 @@ RUN apt-get update && \
RUN echo "StrictHostKeyChecking no" >> /etc/ssh/ssh_config
RUN locale-gen "en_US.UTF-8"

# install Verilator from source to get the right version
RUN apt-get install -y git perl python3 make autoconf g++ flex bison ccache libgoogle-perftools-dev numactl perl-doc libfl2 libfl-dev zlibc zlib1g zlib1g-dev
RUN git clone https://github.com/verilator/verilator
RUN cd verilator && \
git checkout v4.224 && \
autoconf && \
./configure && \
make -j4 && \
make install

# install XRT
RUN wget https://www.xilinx.com/bin/public/openDownload?filename=$XRT_DEB_VERSION.deb -O /tmp/$XRT_DEB_VERSION.deb
RUN apt install -y /tmp/$XRT_DEB_VERSION.deb
Expand All @@ -75,7 +84,7 @@ RUN rm requirements.txt
# extra Python package dependencies (for testing and interaction)
RUN pip install pygments==2.4.1
RUN pip install ipykernel==5.5.5
RUN pip install jupyter==1.0.0
RUN pip install jupyter==1.0.0 --ignore-installed
RUN pip install markupsafe==2.0.1
RUN pip install matplotlib==3.3.1 --ignore-installed
RUN pip install pytest-dependency==0.5.1
Expand Down
2 changes: 1 addition & 1 deletion docker/quicktest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

: ${PYTEST_PARALLEL=auto}

cd $FINN_ROOT/finn
cd $FINN_ROOT
# check if command line argument is empty or not present
if [ -z $1 ]; then
echo "Running quicktest: not (vivado or slow or board) with pytest-xdist"
Expand Down
2 changes: 1 addition & 1 deletion docs/finn/brevitas_export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Two of the Brevitas-exported ONNX variants can be ingested by FINN:

To work with either type of ONNX model, it is loaded into a :ref:`modelwrapper` provided by FINN.

At this stage we can already use the functional verification flow to simulate the model using Python, this is marked in the graphic with the dotted arrow. For more details please have look at :ref:`verification`.
At this stage we can already use the functional verification flow to simulate the model using Python. For more details please have look at :ref:`verification`.

The model can now be further processed in FINN, the next flow step is :ref:`nw_prep`.
16 changes: 8 additions & 8 deletions docs/finn/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,39 +105,39 @@ The following outputs will be generated regardless of which particular outputs a
The other output products are controlled by the `generate_outputs` field in the
build configuration), and are detailed below.

* :py:mod:`finn.builder.build_dataflow.DataflowOutputType.ESTIMATE_REPORTS` produces a variety of reports to estimate resource usage and performance *without* running any synthesis. This can be useful for setting up the parallelization and other hardware configuration:
* :py:mod:`finn.builder.build_dataflow_config.DataflowOutputType.ESTIMATE_REPORTS` produces a variety of reports to estimate resource usage and performance *without* running any synthesis. This can be useful for setting up the parallelization and other hardware configuration:

* ``report/estimate_layer_cycles.json`` -- cycles per layer estimation from analytical model
* ``report/estimate_layer_resources.json`` -- resources per layer estimation from analytical model
* ``report/estimate_layer_config_alternatives.json`` -- resources per layer estimation from analytical model, including what other config alternatives would have yielded
* ``report/estimate_network_performance.json`` -- whole-network performance estimation from analytical model
* ``report/op_and_param_counts.json`` -- per-layer and total number of operations and parameters (independent of parallelization)

* :py:mod:`finn.builder.build_dataflow.DataflowOutputType.STITCHED_IP`: produces a stitched Vivado IP block design that can be integrated with other FPGA designs in Vivado IPI:
* :py:mod:`finn.builder.build_dataflow_config.DataflowOutputType.STITCHED_IP`: produces a stitched Vivado IP block design that can be integrated with other FPGA designs in Vivado IPI:

* ``stitched_ip/finn_vivado_stitch_proj.xpr`` -- Vivado project (including Vivado IP Integrator block design) to generate the stitched IP
* ``stitched_ip/ip`` -- exported Vivado IP for the stitched design

* :py:mod:`finn.builder.build_dataflow.DataflowOutputType.RTLSIM_PERFORMANCE`: measure latency and performance for the stitched IP in RTL simulation, using PyVerilator
* :py:mod:`finn.builder.build_dataflow_config.DataflowOutputType.RTLSIM_PERFORMANCE`: measure latency and performance for the stitched IP in RTL simulation, using PyVerilator

* ``report/rtlsim_performance.json`` -- accelerator throughput and latency from RTL simulation

* :py:mod:`finn.builder.build_dataflow.DataflowOutputType.OOC_SYNTH` runs out-of-context synthesis for the stitched IP. This is useful for getting post-synthesis resource counts and achievable clock frequency without having to produce a full bitfile with DMA engines:
* :py:mod:`finn.builder.build_dataflow_config.DataflowOutputType.OOC_SYNTH` runs out-of-context synthesis for the stitched IP. This is useful for getting post-synthesis resource counts and achievable clock frequency without having to produce a full bitfile with DMA engines:

* ``report/ooc_synth_and_timing.json`` -- resources and achievable clock frequency from out-of-context synthesis

* :py:mod:`finn.builder.build_dataflow.DataflowOutputType.BITFILE` will run Vivado and/or Vitis to insert the FINN accelerator inside a shell, with DMA engines instantiated to move data to/from main memory:
* :py:mod:`finn.builder.build_dataflow_config.DataflowOutputType.BITFILE` will run Vivado and/or Vitis to insert the FINN accelerator inside a shell, with DMA engines instantiated to move data to/from main memory:

* ``bitfile/finn-accel.(bit|xclbin)`` -- generated bitfile depending on platform
* ``report/post_synth_resources.xml`` -- FPGA resource utilization after synthesis
* ``report/post_route_timing.rpt`` -- post-route timing report


* :py:mod:`finn.builder.build_dataflow.DataflowOutputType.PYNQ_DRIVER` will generate a PYNQ Python driver that can be used to interface the generated accelerator:
* :py:mod:`finn.builder.build_dataflow_config.DataflowOutputType.PYNQ_DRIVER` will generate a PYNQ Python driver that can be used to interface the generated accelerator:

* ``driver/driver.py`` -- Python driver that can be used on PYNQ on Zynq or Alveo platforms to launch the accelerator

* :py:mod:`finn.builder.build_dataflow.DataflowOutputType.DEPLOYMENT_PACKAGE`:
* :py:mod:`finn.builder.build_dataflow_config.DataflowOutputType.DEPLOYMENT_PACKAGE`:

* ``deploy/`` -- deployment package folder with a bitfile and driver, ready to be copied to target hardware platform

Expand All @@ -153,7 +153,7 @@ and compare it against the expected output that you provide.

This is achieved by setting up the following members of the build configuration:

* Set ``verify_steps`` to be a list of :py:mod:`finn.builder.build_dataflow.VerificationStepType`
* Set ``verify_steps`` to be a list of :py:mod:`finn.builder.build_dataflow_config.VerificationStepType`
where each element in the list indicates the output of a particular step
that will be verified. See the documentation of the ``VerificationStepType``
for more information.
Expand Down
4 changes: 2 additions & 2 deletions docs/finn/developers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Prerequisites

Before starting to do development on FINN it's a good idea to start
with understanding the basics as a user. Going through all of the
:ref:`tutorials` is strongly recommended if you haven' already done so.
:ref:`tutorials` is strongly recommended if you haven't already done so.
Additionally, please review the documentation available on :ref:`internals`.

Repository structure
Expand Down Expand Up @@ -153,7 +153,7 @@ from the FINN root directory as follows:

::

python setup.py test --addopts "-k test_brevitas_debug --pdb"
pytest -k test_brevitas_debug --pdb


If you want to run tests in parallel (e.g. to take advantage of a multi-core CPU)
Expand Down
2 changes: 1 addition & 1 deletion docs/finn/end_to_end_flow.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ As you can see in the picture, FINN has a high modularity and has the property t
:scale: 50%
:align: center

The white fields show the state of the network representation in the respective step. The colored fields represent the transformations that are applied to the network to achieve a certain result. The diagram is divided into five sections, each of it includes several flow steps. The flow starts in top left corner with Brevitas export (green section), followed by the preparation of the network (blue section) for the Vivado HLS and Vivado IPI (orange section). There is also a section for testing and verification in software (red section) and the hardware generation and deployment on the PYNQ board (yellow section).
The white fields show the state of the network representation in the respective step. The colored fields represent the transformations that are applied to the network to achieve a certain result. The diagram is divided into five sections, each of it includes several flow steps. The flow starts in top left corner with Brevitas export, followed by the preparation of the network for the Vitis HLS and Vivado IPI. There is also a section for testing and verification in software (in the cloud on the right) and the hardware generation and deployment on the PYNQ board.

This example flow is covered in the `end2end_example <https://github.com/Xilinx/finn/tree/main/notebooks/end2end_example>`_ Jupyter notebooks.
For a more detailed overview about the different flow sections, please have a look at the corresponding pages:
Expand Down
Loading

0 comments on commit cdc5ec4

Please sign in to comment.