Tidy up of VGG10 RadioML model #420
-
"the ONNX model has been tidied up by removing the input quantization (See the last paragraph of attached screenshot of readme file provided with finn-example of vgg10-radionl)" How I can perform this removal of input quantization on the onnx file of the sandbox repository https://github.com/Xilinx/brevitas-radioml-challenge-21 . Please suggest steps/ codes. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 13 replies
-
Hi, I attached some Python code in a .txt file: network_surgery.txt We used this code to perform the necessary "tidy up" (aka "network surgery") to make the model ready for FINN, but I have not tested it on the latest Brevitas/FINN versions. It is not very elegant because it works on the .onnx model and not on the Pytorch model level, but it gets the job done. As you see, we remove all nodes before the first "Mul" node. In our case, this includes the (MultiThreshold->Add) sequence that represents the input quantization. We also replace the final Softmax/LogSoftmax node with a TopK node. The rest of it is mostly cleanup steps, some of which might be redundant or not needed anymore. |
Beta Was this translation helpful? Give feedback.
-
Hello @fpjentzsch , as directed by you here, I added "AveragePool" to the list of valid nodes and here . The network surgery operations works fine. But when I observe the .onnx file of the model, after the surgery, I can see that an extra layer named "PAD" is generated before the "AveragePool" layer. We should note that whenever we use a "MaxPool" layer, no such "PAD" layer is generated before it. Using this model for hardware deployment I am getting the following error which I am pretty sure is caused by this extra "PAD" layer only. I am attaching the error screenshot and the log file screenshot too. |
Beta Was this translation helpful? Give feedback.
Hi,
I attached some Python code in a .txt file: network_surgery.txt
We used this code to perform the necessary "tidy up" (aka "network surgery") to make the model ready for FINN, but I have not tested it on the latest Brevitas/FINN versions. It is not very elegant because it works on the .onnx model and not on the Pytorch model level, but it gets the job done.
As you see, we remove all nodes before the first "Mul" node. In our case, this includes the (MultiThreshold->Add) sequence that represents the input quantization. We also replace the final Softmax/LogSoftmax node with a TopK node. The rest of it is mostly cleanup steps, some of which might be redundant or not needed anymore.