Verilog Code generation for my ONNX Model

76 views (last 30 days)
ATHUL
ATHUL on 25 Oct 2024
Edited: Manikanta Aditya on 13 Nov 2024 at 8:44
I have my pretrained pytorch file best.pt and i converted file into ONNX Format . How can i generate verilog code for this File. How can i optimize the Model for my resources in FPGA ? Planning to implement in Zynq Ultrascale MpSoC + Boards

Answers (1)

Subhajyoti
Subhajyoti on 29 Oct 2024 at 14:31
Hi @ATHUL,
It is my understanding that you are trying to generate Verilog code for the ONNX file, and later, planning to deploy it on FPGA boards.
HDL Coder can generate portable, synthesizable Verilog code from MATLAB functions, Simulink models, and Stateflow charts. But currently, the HDL Coder does not support code generation for the function 'importNetworkFromONNX'.
Alternatively, you can create a custom processor configuration and estimate the performance of a pretrained series network. You can then modify parameters of the custom processor configuration and re-estimate the performance. Once you have achieved your performance requirements you can generate a custom bitstream by using the custom processor configuration.
Here, in the following implementation, I have loaded a network from an ONNX file.
% [squeezeNet,ClassNames] = imagePretrainedNetwork("squeezenet");
% exportONNXNetwork(squeezeNet,"squeezeNet.onnx");
net = importNetworkFromONNX("squeezeNet.onnx");
analyzeNetworkForCodegen(net)
You can create, compile, and deploy a 'dlhdl.Workflow' object with the network object by using the Deep Learning HDL Toolbox. Use MATLAB to retrieve the prediction results from the target device. The steps are thoroughly illustrated in the following example:
Additionally, you can refer to the following resources to know more about Custom Deep Learning Processor Generation to Meet Performance Requirements:
  2 Comments
子浩
子浩 on 31 Oct 2024 at 11:47
Thank you very for your help. I have a similar question. I want to deploy my trained CNN network (.pt) onto an FPGA platform, and my development board is ZedBoard instead of ZCU102. Do you know if MATLAB supports this type of deployment? Thank you.
Manikanta Aditya
Manikanta Aditya on 13 Nov 2024 at 8:42
Edited: Manikanta Aditya on 13 Nov 2024 at 8:44
Yes, MATLAB does support deploying trained convolutional neural networks (CNNs) onto FPGA platforms. You can use the Deep Learning HDL Toolbox in MATLAB to create, compile, and deploy your CNNs.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!