Developing with Vitis AI API_3 (Graph Runner) - 1.4.1 English

Vitis AI Library User Guide (UG1354)

Document ID
UG1354
Release Date
2021-12-11
Version
1.4.1 English
When the model is split into multiple subgraphs, it cannot be automatically run with API_0, API_1, and API_2. You have to deploy the model subgraph by subgraph. Graph runner is new API for deploying models in this release. It converts the model into a single graph and makes deployment easier for multiple subgraph models.
  1. Git clone the corresponding Vitis AI Library from https://github.com/Xilinx/Vitis-AI.
  2. Install the cross-compilation system on the host side, refer to Installation.
  3. Check the model to see if it has multiple subgraphs. If yes, you can check whether the ops not supported by DPU are in our supported scope. You can find the operations supported by the Vitis AI Library in Vitis-AI/tools/Vitis-AI-Library/cpu_task/ops.
    Note: If the operation is not in the supported list in cpu_task, then you cannot use the graph_runner directly. You may encounter an error when you compile the model. You must first solve it, then add the operation under cpu_task.
  4. Create the model_test.cpp source file. The main flow is shown in the following figure. See Vitis-AI/demo/Vitis-AI-Library/samples/graph_runner/platenum_graph_runner/platenum_graph_runner.cpp for a complete code example.
    Figure 1. Flow for Developing with Vitis AI API_3

  5. Create a build.sh file as shown below, or copy one from the Vitis AI library demo and modify it.
    result=0 && pkg-config --list-all | grep opencv4 && result=1
    if [ $result -eq 1 ]; then
    	OPENCV_FLAGS=$(pkg-config --cflags --libs-only-L opencv4)
    else
    	OPENCV_FLAGS=$(pkg-config --cflags --libs-only-L opencv)
    fi
    
    CXX=${CXX:-g++}
    $CXX -std=c++17 -O2 -I. \
    	-o platenum_graph_runner \
    	platenum_graph_runner.cpp \
    	-lglog \
    	-lxir \
    	-lvart-runner \
    	-lvitis_ai_library-graph_runner \
    	${OPENCV_FLAGS} \
    	-lopencv_core \
    	-lopencv_imgcodecs \
    	-lopencv_imgproc
  6. Cross compile the program.
    sh -x build.sh
  7. Copy the executable program to the target board using scp.
    scp test_model root@IP_OF_BOARD:~/
  8. Install the latest VART. For more information, refer to Step 3: Installing AI Library Package.
  9. Execute the program on the target board. Before running the program, make sure the target board has the Vitis AI library installed, and prepare the images you want to test.
    ./model_test <model> <image>