Skip to content

Commit 19cbcf6

Browse files
Refactor qnn-data and remove unneeded dependencies (#113)
* Move testcode to tests and notebook code to notebooks * Remove imagenet.py from main finn package * Add missing init py * Exclude tests folder from docstrings requirement * Add missing docstrings * Update imports * Fix last imports * Try adding non python files to test package * Fix missing files * Add vivado scripts to package * update toml * Try fixing missing vivado_scripts * Debug vivado run failures * Try fixing imports in notebooks * Allow copy to not find files * Fix imports * New modular packages for tests and notebooks * Update imports * Fix building wheels * Fix poetry path * Fix poetry paths in .gitlab-ci.yml * Try to get poetry to finally build the wheels for tests and notebooks correctly * Try workaround for poetry bug * Poetry bug workaround * Test CI corruption * Try fixing poetry bug withot breaking the pipeline * Fix notebooks * Fix vivado project generation * Start pruning dependencies * Fix missing wget package in tests * Update gitignore * Try excluding torch and dvc from package * For testing set version fixed to 1.0.1 Uncomment version line and set version to 1.0.1 * Fix version formatting in pyproject.toml * Add missing package dependency definition for subpackages * Fix env dir var resolution for notebooks and tests * Remove qnn-data folder * Fix path in tests * Move pybind dep to poetry and clean up dependencies * Fix fpga module stuff for pipeline * Fix fpga module stuff for pipeline * Make sure Python 3.11 is available. * Fix typo * Bump version of finn-plus extras in toml * Revert Python to 3.10 and add pybind for compatibility until fifo rework * Revert to automatic versioning * Configure dynamic version correctly * Use correct build-system settings for submodules * Set version correctly * Fix linting * Fix docstrings * Add the missing fifos to get_folding_cfg
1 parent 6776da0 commit 19cbcf6

File tree

96 files changed

+1369
-1287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1369
-1287
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,42 @@ jobs:
1616
run: pip install poetry poetry-dynamic-versioning
1717
- name: Config
1818
run: poetry config repositories.pypi https://upload.pypi.org/legacy/
19-
- name: Build
19+
- name: Build subpackages
2020
run: |
21+
# Build tests subpackage
22+
cd tests
2123
poetry install
2224
poetry build
23-
- name: Publish
24-
run: poetry publish -r pypi -u __token__ -p ${{ secrets.PYPI_TOKEN }}
25+
export VERSION=$(poetry version -s)
26+
cd ..
27+
28+
# Build notebooks subpackage
29+
cd notebooks
30+
poetry install
31+
poetry build
32+
cd ..
33+
34+
# Update main pyproject.toml with the correct version
35+
sed -i "s/finn-plus-tests = { version = \"\*\", optional = true }/finn-plus-tests = { version = \"$VERSION\", optional = true }/" pyproject.toml
36+
sed -i "s/finn-plus-notebooks = { version = \"\*\", optional = true }/finn-plus-notebooks = { version = \"$VERSION\", optional = true }/" pyproject.toml
37+
- name: Build main package
38+
run: |
39+
poetry install
40+
poetry build
41+
- name: Publish all packages
42+
run: |
43+
# Publish tests subpackage
44+
cd tests
45+
poetry publish -r pypi -u __token__ -p ${{ secrets.PYPI_TOKEN }}
46+
cd ..
47+
48+
# Publish notebooks subpackage
49+
cd notebooks
50+
poetry publish -r pypi -u __token__ -p ${{ secrets.PYPI_TOKEN }}
51+
cd ..
52+
53+
# Publish main package
54+
poetry publish -r pypi -u __token__ -p ${{ secrets.PYPI_TOKEN }}
2555
test:
2656
runs-on: ubuntu-24.04
2757
needs: deploy
@@ -33,4 +63,4 @@ jobs:
3363
- name: Setup
3464
run: pip install poetry poetry-dynamic-versioning
3565
- name: Install
36-
run: pip install finn-plus==$(poetry version -s)
66+
run: pip install finn-plus[all]==$(poetry version -s)

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ __pycache__/*
4242
*.ipynb_checkpoints*
4343
*.sif
4444
.DS_Store
45+
*.idx
4546

4647
# Project files
4748
.vscode
@@ -54,6 +55,7 @@ tags
5455
poetry.lock
5556
*.code-workspace
5657
.env
58+
*/.cache/*
5759

5860
# Package files
5961
*.egg
@@ -73,6 +75,9 @@ coverage.xml
7375
build/*
7476
dist/*
7577
sdist/*
78+
*/build/*
79+
*/dist/*
80+
*/sdist/*
7681
docs/api/*
7782
docs/_rst/*
7883
docs/_build/*

.gitlab-ci.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,19 @@ Build:
9999
# Let Poetry create virtual environment (.venv) and install Python dependencies
100100
# TODO: is it possible to cache the entire venv for the following jobs?
101101
- poetry install
102-
# Build .whl
102+
- export POETRY_VIRTUALENVS_CREATE=false #DO NOT TOUCH: needed to build sub-packages
103+
# Also build .whl finn-plus-tests package (for test dependencies)
104+
- poetry build -P tests --clean --format=wheel
105+
# Also build .whl finn-plus-notebooks package (for notebooks dependencies)
106+
- poetry build -P notebooks --format=wheel
107+
# Set the version of the sub-packages in the main pyproject.toml
108+
- |
109+
VERSION=$(poetry version -s -C tests)
110+
# Update main pyproject.toml with the correct version
111+
sed -i "s/finn-plus-tests = { version = \"\*\", optional = true }/finn-plus-tests = { version = \"$VERSION\", optional = true }/" pyproject.toml
112+
sed -i "s/finn-plus-notebooks = { version = \"\*\", optional = true }/finn-plus-notebooks = { version = \"$VERSION\", optional = true }/" pyproject.toml
113+
- export POETRY_VIRTUALENVS_CREATE=true #DO NOT TOUCH: revert to default behavior
114+
# Build .whl finn-plus package
103115
- poetry build --clean --format=wheel
104116
# Let FINN download additional dependencies, cache resulting deps directory
105117
# Also fetch & checkout DVC-managed data, $CI_DVC_CACHE_DIR persists between jobs
@@ -112,6 +124,9 @@ Build:
112124
name: "finn-plus_package"
113125
paths:
114126
- dist/*.whl
127+
- tests/dist/*.whl
128+
- notebooks/dist/*.whl
129+
expire_in: 1 week
115130
cache:
116131
key: $CI_COMMIT_SHA #TODO: cache based on relevant files
117132
paths:

ci/.gitlab-setup.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,17 @@
22

33
.n2_setup_general:
44
before_script:
5-
- module load lang/Python/3.10.4-GCCcore-11.3.0
6-
- module load devel/Autoconf/2.71-GCCcore-11.3.0
7-
- module load lang/Bison/3.8.2-GCCcore-11.3.0
8-
- module load lang/flex/2.6.4-GCCcore-11.3.0
9-
- module load lib/pybind11/2.9.2-GCCcore-11.3.0
10-
- module load devel/Boost/1.79.0-GCC-11.3.0
11-
- module load lib/fmt/9.1.0-GCCcore-11.3.0
12-
- module load compiler/GCC/11.3.0
5+
#TODO: switch to python 3.11 and remove pybing module (use poetry dependency only) after FiFO sim rework is merged
6+
- ml lang/Python/3.10.4-GCCcore-11.3.0
7+
- ml lib/pybind11/2.9.2-GCCcore-11.3.0
8+
- ml compiler/GCC/14.2.0 devel/Boost/1.88.0-GCC-14.2.0
139
- ulimit -s unlimited # Increase stack size limit
1410

1511
.n2_setup_xilinx_2022_2:
1612
before_script:
1713
- module load fpga
1814
- module load xilinx/xrt/2.14 # includes Vitis/Vivado 2022.2
15+
- ml fpga/xilinx/vitis_hls_xcd_fix
1916
- export PLATFORM_PATH=$FINN_CUSTOM_PLATFORM_PATH # override with custom platform path
2017
# module load will set PLATFORM_REPO_PATHS to one specific platform, revert to top-level PLATFORM_PATH
2118
- export PLATFORM_REPO_PATHS=$PLATFORM_PATH
@@ -27,6 +24,7 @@
2724
- module load fpga
2825
- module load xilinx/xrt/2.14 # includes Vitis/Vivado 2022.2
2926
- module swap xilinx/vitis/24.2 # switch to Vitis/Vivado 2024.2
27+
- ml fpga/xilinx/vitis_hls_xcd_fix
3028
- export PLATFORM_PATH=$FINN_CUSTOM_PLATFORM_PATH # override with custom platform path
3129
# module load will set PLATFORM_REPO_PATHS to one specific platform, revert to top-level PLATFORM_PATH
3230
- export PLATFORM_REPO_PATHS=$PLATFORM_PATH
@@ -40,6 +38,10 @@
4038
- cd $PATH_WORKDIR
4139
# Create fresh virtual environment and install finn-plus from .whl (artifact)
4240
- python3 -m venv finn-plus-venv
41+
- finn-plus-venv/bin/pip install 'torch~=2.7.1' 'torchvision~=0.22.1' --extra-index-url https://download.pytorch.org/whl/cu121
42+
- finn-plus-venv/bin/pip install 'dvc[webdav]~=3.59.1' 'dvclive[image]~=3.48.2'
43+
- finn-plus-venv/bin/pip install tests/dist/*.whl
44+
- finn-plus-venv/bin/pip install notebooks/dist/*.whl
4345
- finn-plus-venv/bin/pip install dist/*.whl
4446

4547
.setup_full_2022_2:

installDependencies.sh

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,10 @@ XRT_DEB_VERSION="xrt_202220.2.14.354_22.04-amd64-xrt"
44

55
sudo apt-get update && sudo apt-get install -y \
66
build-essential \
7-
libc6-dev-i386 \
8-
libglib2.0-0 \
9-
libsm6 \
10-
libxext6 \
11-
libxrender-dev \
12-
zsh \
137
zip \
14-
perl \
158
make \
16-
autoconf \
179
g++ \
18-
flex \
19-
bison \
20-
ccache \
21-
libgoogle-perftools-dev \
22-
numactl \
23-
perl-doc \
24-
libfl2 \
25-
libfl-dev \
26-
zlib1g \
2710
zlib1g-dev \
28-
pybind11-dev \
29-
libfmt-dev \
30-
libboost-dev \
31-
libjansson-dev \
32-
libgetdata-dev \
33-
g++-10 \
34-
libpython3.10-dev \
35-
python3.10-dev \
3611
libboost-all-dev
3712

3813
xrt_found=$(dpkg -l | grep xrt | wc -l)

notebooks/advanced/0_custom_analysis_pass.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"metadata": {},
1818
"outputs": [],
1919
"source": [
20-
"from finn.util.visualization import showSrc, showInNetron"
20+
"from notebooks.notebook_utils import showSrc, showInNetron"
2121
]
2222
},
2323
{

notebooks/advanced/1_custom_transformation_pass.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"metadata": {},
1818
"outputs": [],
1919
"source": [
20-
"from finn.util.visualization import showSrc, showInNetron"
20+
"from notebooks.notebook_utils import showSrc, showInNetron"
2121
]
2222
},
2323
{

notebooks/advanced/3_folding.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"metadata": {},
2424
"outputs": [],
2525
"source": [
26-
"from finn.util.visualization import showInNetron, showSrc"
26+
"from notebooks.notebook_utils import showInNetron, showSrc"
2727
]
2828
},
2929
{

notebooks/advanced/4_advanced_builder_settings.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
"metadata": {},
6262
"outputs": [],
6363
"source": [
64-
"from finn.util.visualization import showInNetron, showSrc\n",
64+
"from notebooks.notebook_utils import showInNetron, showSrc\n",
6565
"import os\n",
6666
" \n",
6767
"build_dir = os.environ['FINN_NOTEBOOKS'] + \"/advanced\""
@@ -83,7 +83,7 @@
8383
"outputs": [],
8484
"source": [
8585
"import torch\n",
86-
"from finn.util.test import get_test_model_trained\n",
86+
"from notebooks.notebook_utils import get_test_model_trained\n",
8787
"from brevitas.export import export_qonnx\n",
8888
"from qonnx.util.cleanup import cleanup as qonnx_cleanup\n",
8989
"\n",
@@ -387,7 +387,7 @@
387387
"metadata": {},
388388
"outputs": [],
389389
"source": [
390-
"from finn.util.pytorch import ToTensor\n",
390+
"from notebooks.notebook_utils import ToTensor\n",
391391
"from qonnx.transformation.merge_onnx_models import MergeONNXModels\n",
392392
"from qonnx.core.modelwrapper import ModelWrapper\n",
393393
"from qonnx.core.datatype import DataType\n",
@@ -1350,7 +1350,7 @@
13501350
"outputs": [],
13511351
"source": [
13521352
"# Get golden io pair from Brevitas and save as .npy files\n",
1353-
"from finn.util.test import get_trained_network_and_ishape, get_example_input, get_topk\n",
1353+
"from notebooks.notebook_utils import get_trained_network_and_ishape, get_example_input, get_topk\n",
13541354
"import numpy as np\n",
13551355
"\n",
13561356
"\n",

0 commit comments

Comments
 (0)