-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cleanup function and ConvertQONNXtoFINN transformation issue #892
Comments
@auphelia Could you help on this issue, please? |
Seems to be related to or even the same as one of the issues I am currently investigating: #878 (the third one from the list). However, I am not really making any progress on this particular one besides tracking it down to the At least in my case, probably I just do not want to apply the transformation to the transpose at all (as it is part of the attention pattern). But for this, conditions for telling various uses of the transpose apart will be needed... Did you make any progress by now @williamliao28? Otherwise, some input from you FINN people would be appreciated @auphelia @maltanar. |
For me it seems like currently all occurrences of the |
Closing this as the issue was most likely fixed in fastmachinelearning/qonnx#78. |
name: Bug report
about: Something isn't working as expected
title: 'cleanup function and ConvertQONNXtoFINN transformation issue'
labels: bug
assignees: ''
Prerequisites
Quick summary
FINN cannot successfully convert a QONNX model with transpose before concatenation layer.
Details
Any suggestions are welcomed. I have tried the following experiments for this issue.
cleanup()
and runningConvertQONNXtoFINN()
. However, I get the following error message:onnx.onnx_cpp2py_export.shape_inference. Inferencerror: [ShapeInferenceError] (op_type: Cast, node name: Quant_4): [ShapeInferenceError] Inferred shape and existing shape differ in dimension 1: (64) vs (28)
. The traceback message is included in the screenshot posted below.cleanup()
function (inqonnx/util/cleanup.py
) and theConvertQONNXtoFINN()
transformation (infinn/transformation/qonnx/convert_qonnx_to_finn.py
). I found that they both call the transformationFoldTransposeIntoQuantInit()
(line 40 incleanup.py
and line 81 inconvert_qonnx_to_finn.py
). This transformation attempts to fuse atranspose
node into previousQuant
orBipolarQuant
node, and do a shape inference before returning the transformed model. It seems to assume that the transpose is 2D or does not involve channel dimension. When performing shape inference, it is expected thatQuant
orBipolarQuant
nodes corresponding to quantized activation layers should havein_channel == out_channel
. My test model has transpose involving channel dimension, so it fails.Steps to Reproduce
I include example python codes in the links below which may be useful for reproducing the error. The file
simple_test.py
contains the PyTorch module defining the model with Brevitas quantization. The filesimple_test_qonnx2finn.py
is the code I run inside the FINN docker and this one produce the error message described above. The filesimple_test_w1a1_cifar10_2epoch.onnx
is a pertained model which can be used directly as the input forsimple_test_qonnx2finn.py
.simple_test.py
simple_test_qonnx2finn.py
simple_test_w1a1_cifar10_2epoch.onnx
bash ./run_docker.sh
simple_test_w1a1_cifar10_2epoch.onnx
under the directorybuild/quant_model/simple_test_cifar10/lr0.02
python simple_test_qonnx2finn.py
Expected behavior
The code
simple_test_qonnx2finn.py
should be run without any errors and produce the converted model.Actual behavior
Running
python simple_test_qonnx2finn.py
generates the error described above.The text was updated successfully, but these errors were encountered: