Metadata-Version: 2.4
Name: finn-plus-driver
Version: 1.6.2
Summary: PYNQ runtime driver for FPGA accelerators generated by finn-plus
Maintainer: Felix Jentzsch
Maintainer-email: felix.jentzsch@upb.de
Requires-Python: >=3.10
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Requires-Dist: bitstring (>=4.0)
Requires-Dist: click (>=8.0)
Requires-Dist: finn-dataset-loading (>=0.0.5)
Requires-Dist: grpcio (==1.64.0)
Requires-Dist: h5py (>=3.0)
Requires-Dist: matplotlib (>=3.4)
Requires-Dist: numpy (>=1.21,<2.0.0)
Requires-Dist: pillow (>=9.0)
Requires-Dist: qonnx (>=1.0.0)
Project-URL: EKI Project, https://www.eki-project.tech/
Project-URL: GitHub, https://github.com/eki-project/finn-plus
Description-Content-Type: text/markdown

# finn-plus-driver

Runtime driver for FPGA accelerators generated by
[finn-plus](https://github.com/eki-project/finn-plus) and deployed to ZYNQ/PYNQ boards.

This package contains everything needed to *run* a FINN-generated accelerator and nothing
of the compiler itself. It is installed on the board, while the accelerator-specific
artifacts (bitfile, `settings.json`, runtime weights) are produced by the finn-plus build
flow and copied to the board separately.

## Installation

On a PYNQ board, inside the PYNQ virtual environment:

```bash
sudo pip install finn-plus-driver
```

`pynq` itself is not declared as a dependency: it is part of the board image.

To install the version matching a repository checkout (e.g. in CI):

```bash
sudo pip install ./driver
```

## Usage

The driver is usually invoked through its CLI, which instantiates the driver class named in
`settings.json` and calls one of its member functions:

```bash
finn-plus-driver -b bitfile/finn-accel.bit -s driver/settings.json -f throughput_test
```

It can equally be used as a library:

```python
from finn_plus_driver import FINNDMAOverlay

accel = FINNDMAOverlay("finn-accel.bit", io_shape_dict=io_shape_dict)
output = accel.execute(input_array)
```

## Contents

| Module | Purpose |
| --- | --- |
| `finn_plus_driver.overlays.dma` | `FINNDMAOverlay`, the standard DMA-based accelerator driver |
| `finn_plus_driver.overlays.instrumentation` | `FINNInstrumentationOverlay`, DMA-less instrumentation runs |
| `finn_plus_driver.overlays.live_fifo` | `FINNLiveFIFOOverlay`, live FIFO sizing experiments |
| `finn_plus_driver.overlays.dma_instrumentation` | `FINNDMAInstrumentationOverlay`, combined DMA + instrumentation |
| `finn_plus_driver.packing` | Data packing/unpacking between numpy and the accelerator's bit-level format |
| `finn_plus_driver.validate` | Dataset-specific accuracy validation, see [Validation datasets](#validation-datasets) |
| `finn_plus_driver.cli` | Command line interface |

## Validation datasets

The `validate` function of the DMA-based drivers runs the accelerator on the validation data of
the dataset named by `validation_dataset` in `settings.json` and writes the top-1 accuracy to
`report_dma_validate.json`. MNIST and CIFAR are downloaded on first use, all other datasets are
read from the directory that the `DATASET_DIR` environment variable points to (or from the path
given as `dataset_path`):

| `validation_dataset` | Dataset | Expected in `$DATASET_DIR` |
| --- | --- | --- |
| `mnist` | MNIST test set | downloaded |
| `cifar`, `cifar100` | CIFAR-10 / CIFAR-100 test set | downloaded |
| `imagenet` | ILSVRC2012 validation set | `ImageNet2012/ILSVRC2012_img_val/`, `ImageNet2012/val.txt` |
| `radioml` | RadioML 2018.01A, highest-SNR test samples (VGG10 model) | `GOLD_XYZ_OSC.0001_1024.hdf5` |
| `radioml_transformer` | RadioML 2018.01A, evaluation split of the finn-transformers model | `GOLD_XYZ_OSC.0001_1024.hdf5` |
| `unswnb15` | UNSW-NB15 (binarized) test set | `unsw_nb15_binarized.npz` |
| `speechcommands` | Google Speech Commands v2 validation split, as MFCC features | `python_speech_preprocessing_all_validation_KWS_data.npz` |
| `gtsrb` | GTSRB test set, scaled to 32x32 pixels | `gtsrb_test_32x32.npz` |
| `tinystories` | TinyStories validation split as masked token sequences | `tinystories_validation_mlm.npz` |

The files for `speechcommands`, `gtsrb` and `tinystories` are fetched and converted by
`scripts/prepare_validation_datasets.py` of the finn-plus repository.

The inputs are converted to what the accelerator expects: the CIFAR images are normalized and
the RadioML and Speech Commands samples are left unquantized for accelerators with a float
input, whose input quantizer is part of the hardware. For `tinystories` the reported top-1
accuracy is the share of masked tokens that were predicted correctly.

