YoloV5 TVM Implementation Guide

From Renesas.info

This is a simple example of implementing the Renesas TVM using YoloV5.

YoloV5 Preparation

This sample will download the YoloV5 from this website.


  • pytorch
  • python
  • git

Download YoloV5s ONNX

This script by downloads the YoloV5s pt file and creates the onnx file. The input image size is set to 640x640.

YoloV5 supports various input resolutions. By default the script sets the input image size to 640x640.

python export.py --weights yolov5s.pt --include onnx

To change the size use the --imgsz option

python export.py --weights yolov5s.pt --imgsz [640, 480] --include onnx

Get NN Input Information

The TVM Scripts needs the NN input name and shape. The python library onnx can provide this information or this cloud application Netron

  • NN Input Node Name : images
  • NN Input Node Shape: 1,3,640,640

YoloV5 Translate

This section shows how to translate the aquired onnx file to the TVM inference. The Renesas TVM includes python scripts for converting onnx files for the RZV2MA DRP-AI.  These can be found in the drp-ai_tvm/tutorials directory.

ONNX Compiler

For this example we used the onnx compiler scripts.


python3 compile_onnx_model.py \
./yolov5s.onnx \
-o yolov5s_onnx \
-s 1,3,640,640 \
-i images


[DRP converter] Success & Finished

[Generate address map file] Start
  > aimac_desc.bin size :   0x19cb0 (105648 Byte)
  > drp_desc.bin size   :     0xd60 (3424 Byte)
  > drp_param.bin size  :    0x1000 (4096 Byte)
  [Address & data alignment check] PASS
  [Check address map overlap (memory leak)] PASS
  Address map file: ./temp/20221024_171747/tvmgen_default_tvmgen_default_mera_drp_0/drp_compilation_output/out_addrmap_intm.yaml is generated.
[Generate address map file] Finish
[Make Input/Output node information]
  Input node list : ./temp/20221024_171747/tvmgen_default_tvmgen_default_mera_drp_0/drp_compilation_output/out_data_in_list.txt is generated.
  Output node list : ./temp/20221024_171747/tvmgen_default_tvmgen_default_mera_drp_0/drp_compilation_output/out_data_out_list.txt is generated.

CPU Only

python3 compile_cpu_only_onnx_model.py \
    ./yolov5s.onnx \
    -o yolov5s_onnx \
    -s 1,3,640,640 \
    -i images