xdputil ツールの使用法 - 3.5 日本語

Vitis AI ライブラリ ユーザー ガイド (UG1354)

Document ID
UG1354
Release Date
2023-06-29
Version
3.5 日本語

xdputil は、ボード開発用に設計されています。これはエッジ デバイスとデータセンター ターゲットのいずれにも使用できます。最新のボード イメージまたは Docker にインストールされています。xdputil のソース コードは、Vitis-AI/src/vai_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 サブグラフの場合、xdputil benchmark の subgraph_index に 0 は指定できません。

ここでは、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
モデルで 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]
注記: xdputil を Docker で使用する場合は、xdputil の代わりに /usr/bin/python3 -m xdputil を使用します。たとえば、/usr/bin/python3 -m xdputil query のように指定します。