Xilinx / finn

Dataflow compiler for QNN inference on FPGAs
https://xilinx.github.io/finn
BSD 3-Clause "New" or "Revised" License
747 stars 238 forks source link

OPSET and Assuming 4D input is NCHW #993

Open Ba1tu3han opened 8 months ago

Ba1tu3han commented 8 months ago

Prerequisites

Please make sure to check off these prerequisites before submitting a bug report.

Quick summary

I trained Brevitas CNV model on CIFAR10 dataset by using QAT and exported it by this scpript

from brevitas.export import export_qonnx
input_tensor = torch.randn(batch_size, n_channel, shape_x, shape_y).to(device)
export_qonnx(model, input_tensor, export_path='QONNX_CNV.onnx')

Then, imported it to tfc_end2end_example.ipynb

Unfortunately, I have encountered with warnings and errors:

image image

Details

QONNX File QONNX_CNV.zip

Brevitas

Brevitas: 0.10.2 Ubuntu: 20.04 Python: 3.10.12 Torch: 2.1.0 CUDA: 12.2

FINN

FINN: 0.10 (tag: dev_latest) Docker: 25.0.1 Vivado: 2022.1 Vitis HLS: 2022.1 Ubuntu: 20.04 Python: 3.11.5

Error:

AssertionError: MultiThreshold_6: Signed output requres actval < 0

Possible fix

Using an extra convertion or a setting

Ba1tu3han commented 2 months ago

@auphelia could you help me about that?

I follow cnv_end2end_example notebook. I can implement W1A1 version that I trained CNV by Brevitas succesfully in Pynq-Z2. However I just change quantization from 1 bit to 2 bits, I have this issue. Where should I look?

I have checked similar github issues but I could not find a solution.

Bests,