Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into feature/ultra96v2-su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
auphelia committed Nov 7, 2023
2 parents 6c0f869 + a0a0586 commit 3c40245
Show file tree
Hide file tree
Showing 278 changed files with 18,277 additions and 18,043 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ name: DockerImage

on:
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.10'

- 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
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
line_length=88
indent=' '
skip=.tox,.venv,build,dist
known_standard_library=setuptools,pkg_resources
known_standard_library=setuptools
known_test=pytest
known_first_party=finn
sections=FUTURE,STDLIB,TEST,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
Expand Down
15 changes: 8 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
exclude: '^docs/conf.py'

default_language_version:
python: python3.8
python: python3.10

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: '\.dat$'
Expand All @@ -51,20 +51,21 @@ repos:
args: ['--fix=no']

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

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.3.0
hooks:
- id: black
language_version: python3
args: [--line-length=100]

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
# black-compatible flake-8 config
args: ['--max-line-length=88', # black default
args: ['--max-line-length=100', # black default
'--extend-ignore=E203'] # E203 is not PEP8 compliant
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
51 changes: 36 additions & 15 deletions docker/Dockerfile.finn
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
# 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.

FROM pytorch/pytorch:1.7.1-cuda11.0-cudnn8-runtime
FROM ubuntu:jammy-20230126
LABEL maintainer="Yaman Umuroglu <[email protected]>"

ARG XRT_DEB_VERSION="xrt_202210.2.13.466_18.04-amd64-xrt"
ARG XRT_DEB_VERSION="xrt_202220.2.14.354_22.04-amd64-xrt"

WORKDIR /workspace

Expand All @@ -46,7 +46,6 @@ RUN apt-get update && \
libsm6 \
libxext6 \
libxrender-dev \
verilator \
nano \
zsh \
rsync \
Expand All @@ -58,10 +57,23 @@ RUN apt-get update && \
unzip \
zip \
locales \
lsb-core
lsb-core \
python3 \
python-is-python3 \
python3-pip
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 make autoconf g++ flex bison ccache libgoogle-perftools-dev numactl perl-doc libfl2 libfl-dev 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 @@ -72,22 +84,31 @@ RUN rm /tmp/$XRT_DEB_VERSION.deb
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN rm requirements.txt

# install PyTorch
RUN pip install torch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116

# 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 pygments==2.14.0
RUN pip install ipykernel==6.21.2
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 matplotlib==3.7.0 --ignore-installed
RUN pip install pytest-dependency==0.5.1
RUN pip install sphinx==5.0.2
RUN pip install sphinx_rtd_theme==0.5.0
RUN pip install pytest-xdist[setproctitle]==2.4.0
RUN pip install pytest-parallel==0.1.0
RUN pip install pytest-xdist[setproctitle]==3.2.0
RUN pip install pytest-parallel==0.1.1
RUN pip install "netron>=5.0.0"
RUN pip install pandas==1.1.5
RUN pip install scikit-learn==0.24.1
RUN pip install tqdm==4.31.1
RUN pip install pandas==1.5.3
RUN pip install scikit-learn==1.2.1
RUN pip install tqdm==4.64.1
RUN pip install -e git+https://github.com/fbcotter/[email protected]#egg=dataset_loading
# these versions of pytest and associated plugins allow for stable collection of
# test reports and code coverage reports in HTML
RUN pip install pytest==6.2.5
RUN pip install pytest-metadata==1.7.0
RUN pip install pytest-html==3.0.0
RUN pip install pytest-html-merger==0.0.8
RUN pip install pytest-cov==4.1.0

# extra dependencies from other FINN deps
# installed in Docker image to make entrypoint script go faster
Expand Down
26 changes: 24 additions & 2 deletions docker/finn_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ recho () {
echo -e "${RED}ERROR: $1${NC}"
}

# qonnx
pip install --user -e ${FINN_ROOT}/deps/qonnx
# qonnx (using workaround for https://github.com/pypa/pip/issues/7953)
# to be fixed in future Ubuntu versions (https://bugs.launchpad.net/ubuntu/+source/setuptools/+bug/1994016)
pip install --no-build-isolation --no-warn-script-location -e ${FINN_ROOT}/deps/qonnx
# finn-experimental
pip install --user -e ${FINN_ROOT}/deps/finn-experimental
# brevitas
Expand Down Expand Up @@ -113,6 +114,27 @@ else
yecho "If you need Vitis HLS, ensure HLS_PATH is set correctly and mounted into the Docker container."
fi

if [ -d "$FINN_ROOT/.Xilinx" ]; then
mkdir "$HOME/.Xilinx"
if [ -f "$FINN_ROOT/.Xilinx/HLS_init.tcl" ]; then
cp "$FINN_ROOT/.Xilinx/HLS_init.tcl" "$HOME/.Xilinx/"
gecho "Found HLS_init.tcl and copied to $HOME/.Xilinx/HLS_init.tcl"
else
yecho "Unable to find $FINN_ROOT/.Xilinx/HLS_init.tcl"
fi

if [ -f "$FINN_ROOT/.Xilinx/Vivado/Vivado_init.tcl" ]; then
mkdir "$HOME/.Xilinx/Vivado/"
cp "$FINN_ROOT/.Xilinx/Vivado/Vivado_init.tcl" "$HOME/.Xilinx/Vivado/"
gecho "Found Vivado_init.tcl and copied to $HOME/.Xilinx/Vivado/Vivado_init.tcl"
else
yecho "Unable to find $FINN_ROOT/.Xilinx/Vivado/Vivado_init.tcl"
fi
else
echo "If you need to enable a beta device, ensure .Xilinx/HLS_init.tcl and/or .Xilinx/Vivado/Vivado_init.tcl are set correctly and mounted"
echo "See https://docs.xilinx.com/r/en-US/ug835-vivado-tcl-commands/Tcl-Initialization-Scripts"
fi

export PATH=$PATH:$HOME/.local/bin
# execute the provided command(s) as root
exec "$@"
Loading

0 comments on commit 3c40245

Please sign in to comment.