使用 xdputil 工具 - 2.5 简体中文

Vitis AI Library 用户指南 (UG1354)

Document ID
UG1354
Release Date
2022-06-15
Version
2.5 简体中文

xdputil 是专为开发板的开发而设计的。它可用于边缘器件和云端器件。它安装在最新的开发板镜像或 Docker 中。xdputil 源代码位于 Vitis-AI/src/Vitis-AI-Library/usefultools 文件夹内。它包含以下函数。

help
显示 xdputil 的用法。
xdputil --help
status
显示 DPU 的状态。
xdputil status
run
利用输入文件来运行 DPU。它可用于 DPU 交叉检查。
xdputil run <xmodel> [-i <subgraph_index>] <input_bin>

xmodel: The model run on DPU
-i : The subgraph_index of the model, the default value is 0
input_bin: The input file for the model

resnet50.xmodel 为例。


root@xilinx-zcu104-2021_2:~# xdputil run /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel input.bin
fillin data_fixed
dump output to 0.fc1000_fixed.bin
xmodel
检查 xmodel 信息。您可将 xmodel 转换为 png/svg/txt 格式。运行以下命令显示 xmodel 的用法。
root@xilinx-zcu102-20221:~# xdputil xmodel -h

usage: xdputil.py xmodel [-h] [-l] [--op [OP]] [-m] [-p [PNG]] [-s [SVG]] [-S [SUBGRAPH_SVG]] [-t [TXT]] [-b [BINARY]] xmodel


xmodel


positional arguments:
xmodel xmodel file path


optional arguments:
  -h, --help show this help message and exit
  -l, --list show subgraph list
  --op [OP]             show op info
  -m, --meta_info show xcompiler version
  -p [PNG], --png [PNG]
        the output to png
  -s [SVG], --svg [SVG]
        the output svg path
  -S [SUBGRAPH_SVG], --subgraph_svg [SUBGRAPH_SVG]
        the output svg for subgraph level
  -t [TXT], --txt [TXT]
        when <txt> is missing, it dumps to standard output.
  -b [BINARY], --binary [BINARY]
        dump the binary data to the output directory, when  is missing, it dumps to 'binary' directory
mem
读取或写入物理存储器。该函数类似于 devmem
xdputil mem <-r|-w> <addr> <size> <output_file|input_file>
query
显示器件信息,包括 DPU、指纹和 Vitis AI 版本。
xdputil query
benchmark
显示测试模型的性能。返回的值为每秒帧数 (fps)。
xdputil benchmark <xmodel> <-i subgraph_index> <num_of_threads>

-i : The subgraph_index of the model, index starts from 0, -1 means running the whole graph.
注释: 如果首个子图是 USER 子图,那么当 subgraph_index 为 0 时,xdputil benchmark 无法工作。

resnet50.xmodel 为例。


root@xilinx-zcu102-2021_2:~# xdputil benchmark /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel -i -1 5
WARNING: Logging before InitGoogleLogging() is written to STDERR
I1229 23:39:07.248836 8713 test_dpu_runner_mt.cpp:473] shuffle results for batch...
I1229 23:39:07.252218 8713 performance_test.hpp:73] 0% ...
I1229 23:39:13.252394 8713 performance_test.hpp:76] 10% ...
I1229 23:39:19.252584 8713 performance_test.hpp:76] 20% ...
I1229 23:39:25.252804 8713 performance_test.hpp:76] 30% ...
I1229 23:39:31.253026 8713 performance_test.hpp:76] 40% ...
I1229 23:39:37.253317 8713 performance_test.hpp:76] 50% ...
I1229 23:39:43.253564 8713 performance_test.hpp:76] 60% ...
I1229 23:39:49.253836 8713 performance_test.hpp:76] 70% ...
I1229 23:39:55.254051 8713 performance_test.hpp:76] 80% ...
I1229 23:40:01.254329 8713 performance_test.hpp:76] 90% ...
I1229 23:40:07.254683 8713 performance_test.hpp:76] 100% ...
I1229 23:40:07.254791 8713 performance_test.hpp:79] stop and waiting for all threads terminated....
I1229 23:40:07.265725 8713 performance_test.hpp:85] thread-0 processes 2266 frames
I1229 23:40:07.265758 8713 performance_test.hpp:85] thread-1 processes 2072 frames
I1229 23:40:07.265779 8713 performance_test.hpp:85] thread-2 processes 2637 frames
I1229 23:40:07.278290 8713 performance_test.hpp:85] thread-3 processes 2280 frames
I1229 23:40:07.279388 8713 performance_test.hpp:85] thread-4 processes 2052 frames
I1229 23:40:07.279413 8713 performance_test.hpp:93] it takes 24599 us for shutdown
I1229 23:40:07.279430 8713 performance_test.hpp:94] FPS= 188.365 number_of_frames= 11307 time= 60.0272 seconds.
I1229 23:40:07.279479 8713 performance_test.hpp:96] BYEBYE
Test PASS.
run_op
在模型中运行该运算符。
xdputil run_op <xmodel> <op_name> [-r REF_DIR] [-d DUMP_DIR]

运行以下命令显示 run_op 的用法。

root@xilinx-zcu102-2021_2:~# xdputil run_op  -h
usage: xdputil.py run_op [-h] [-r REF_DIR] [-d DUMP_DIR] xmodel op_name

positional arguments:
  xmodel                xmodel file name
  op_name               op name, this op_name should be consistent with the name in xmodel

optional arguments:
  -h, --help            show this help message and exit
  -r REF_DIR, --ref_dir REF_DIR
                        reference directory, this directory default as "ref" should contain inputs tensor file like
                        <TENSOR_NAME>.bin
  -d DUMP_DIR, --dump_dir DUMP_DIR
                        dump directory, this directory default as "dump" will be the dump destination of output tensor
                        file
comp_float
比较黄金文件与转储文件,尤其是其中包含浮点值时。
xdputil comp_float <golden_file> <dump_file> [-t threshold] [--verbose]
注释: 在 Docker 中使用 xdputil 时,使用 /usr/bin/python3 -m xdputil 代替 xdputil。例如,/usr/bin/python3 -m xdputil query