FC2カウンター FPGAの部屋 テンプレートで書いた畳み込みニューラルネットワークをRTLカーネルとしてVitisで実装する2(Vivado HLS 編 2)
fc2ブログ

FPGAやCPLDの話題やFPGA用のツールの話題などです。 マニアックです。 日記も書きます。

FPGAの部屋

FPGAの部屋の有用と思われるコンテンツのまとめサイトを作りました。Xilinx ISEの初心者の方には、FPGAリテラシーおよびチュートリアルのページをお勧めいたします。

テンプレートで書いた畳み込みニューラルネットワークをRTLカーネルとしてVitisで実装する2(Vivado HLS 編 2)

テンプレートで書いた畳み込みニューラルネットワークをRTLカーネルとしてVitisで実装する1(Vivado HLS 編 1)”の続き。

前回は、Vitis のRTL カーネルとして実装するためのC++ のソースコードテストベンチを貼った。今回は、そのコードをVivado HLS 2019.2 でプロジェクトを作成して実装していこう。

最初に all_layers_template プロジェクトを示す。
RTL_kernel_9_191228.png

RTL_kernel_10_191228.png

このように層ごとにたくさんのファイルを入れてある。
なお、”Vitis のRTL カーネル”にあるように、Solution メニューから Solution Settings... を選択して、

config_interface -m_axi_addr64
config_sdx -target xocc

オプションを入れた。
RTL_kernel_17_191229.png

最初に C シミュレーションを行った。
(2020/01/02 :追記) C シミュレーションは all_layers_template_axim.cpp の extern "C" { } をコメントアウトしています。そうしなければ C シミュレーションがエラーになります。
RTL_kernel_11_191228.png

INFO: [SIM 2] *************** CSIM start ***************
INFO: [SIM 4] CSIM will launch GCC as the compiler.
   Compiling ../../../all_layers_template_axim.cpp in debug mode
   Compiling ../../../hw_ip/conv_layer1.cpp in debug mode
   Compiling ../../../hw_ip/input_layer.cpp in debug mode
   Compiling ../../../hw_ip/max_pooling.cpp in debug mode
   Compiling ../../../hw_ip/output_layer.cpp in debug mode
   Compiling ../../../hw_ip/relu_affine1.cpp in debug mode
   Compiling ../../../hw_ip/relu_conv1.cpp in debug mode
   Generating csim.exe
hw_error: i = 25 output = 2 t_test_num = 1
sw_error: i = 25 output_soft = 2 t_test_num = 1
dot2[0] = -5.00000000   dot2_soft[0] = -3.77501726
dot2[1] = 0.00000000    dot2_soft[1] = -0.13269189
dot2[2] = 0.00000000    dot2_soft[2] = 1.61074853

hw_error: i = 30 output = 2 t_test_num = 1
sw_error: i = 30 output_soft = 2 t_test_num = 1
dot2[0] = -6.00000000   dot2_soft[0] = -4.67336369
dot2[1] = 0.00000000    dot2_soft[1] = 0.12951475
dot2[2] = 0.00000000    dot2_soft[2] = 1.71587336

sw_error: i = 31 output_soft = 2 t_test_num = 1
dot2[0] = -7.00000000   dot2_soft[0] = -5.31440449
dot2[1] = 0.00000000    dot2_soft[1] = 0.69655895
dot2[2] = 0.00000000    dot2_soft[2] = 1.00723171

sw_error: i = 35 output_soft = 2 t_test_num = 1
dot2[0] = -7.00000000   dot2_soft[0] = -5.15462875
dot2[1] = 0.00000000    dot2_soft[1] = 0.19586089
dot2[2] = 0.00000000    dot2_soft[2] = 1.79063916

sw_error: i = 36 output_soft = 2 t_test_num = 1
dot2[0] = -7.00000000   dot2_soft[0] = -5.64889669
dot2[1] = 1.00000000    dot2_soft[1] = 0.69646239
dot2[2] = 0.00000000    dot2_soft[2] = 1.09402716

sw_error: i = 40 output_soft = 2 t_test_num = 1
dot2[0] = -7.00000000   dot2_soft[0] = -5.31394196
dot2[1] = 0.00000000    dot2_soft[1] = 0.30034199
dot2[2] = 0.00000000    dot2_soft[2] = 1.52586949

sw_error: i = 41 output_soft = 2 t_test_num = 1
dot2[0] = -8.00000000   dot2_soft[0] = -5.94443941
dot2[1] = 0.00000000    dot2_soft[1] = 0.61903512
dot2[2] = 0.00000000    dot2_soft[2] = 1.28180122

sw_error: i = 42 output_soft = 2 t_test_num = 1
dot2[0] = -10.00000000  dot2_soft[0] = -7.44187164
dot2[1] = 1.00000000    dot2_soft[1] = 1.10615981
dot2[2] = 0.00000000    dot2_soft[2] = 1.35738707

sw_error: i = 45 output_soft = 2 t_test_num = 1
dot2[0] = -8.00000000   dot2_soft[0] = -5.92508411
dot2[1] = 0.00000000    dot2_soft[1] = 0.44851223
dot2[2] = 0.00000000    dot2_soft[2] = 1.43742454

sw_error: i = 46 output_soft = 2 t_test_num = 1
dot2[0] = -10.00000000  dot2_soft[0] = -7.76649952
dot2[1] = 1.00000000    dot2_soft[1] = 0.82863915
dot2[2] = 0.00000000    dot2_soft[2] = 1.88942850

sw_error: i = 47 output_soft = 2 t_test_num = 1
dot2[0] = -12.00000000  dot2_soft[0] = -9.50911713
dot2[1] = 1.00000000    dot2_soft[1] = 1.48399019
dot2[2] = 0.00000000    dot2_soft[2] = 1.85759318

hw_error: i = 75 output = 2 t_test_num = 1
sw_error: i = 75 output_soft = 2 t_test_num = 1
dot2[0] = -5.00000000   dot2_soft[0] = -4.04238653
dot2[1] = -1.00000000   dot2_soft[1] = -1.22402656
dot2[2] = 2.00000000    dot2_soft[2] = 3.36929369

hw_error: i = 76 output = 2 t_test_num = 1
sw_error: i = 76 output_soft = 2 t_test_num = 1
dot2[0] = -6.00000000   dot2_soft[0] = -4.09871578
dot2[1] = 0.00000000    dot2_soft[1] = -0.46985394
dot2[2] = 0.00000000    dot2_soft[2] = 1.61257589

hw_error: i = 80 output = 2 t_test_num = 1
sw_error: i = 80 output_soft = 2 t_test_num = 1
dot2[0] = -6.00000000   dot2_soft[0] = -4.33292818
dot2[1] = 0.00000000    dot2_soft[1] = -0.96692348
dot2[2] = 1.00000000    dot2_soft[2] = 2.98383069

hw_error: i = 81 output = 2 t_test_num = 1
sw_error: i = 81 output_soft = 2 t_test_num = 1
dot2[0] = -6.00000000   dot2_soft[0] = -4.40864801
dot2[1] = 0.00000000    dot2_soft[1] = -0.15780880
dot2[2] = 0.00000000    dot2_soft[2] = 1.26864278

hw_error: i = 85 output = 2 t_test_num = 1
sw_error: i = 85 output_soft = 2 t_test_num = 1
dot2[0] = -6.00000000   dot2_soft[0] = -4.16326904
dot2[1] = 0.00000000    dot2_soft[1] = -0.84592772
dot2[2] = 1.00000000    dot2_soft[2] = 2.42255425

sw_error: i = 86 output_soft = 2 t_test_num = 1
dot2[0] = -6.00000000   dot2_soft[0] = -4.36515617
dot2[1] = 0.00000000    dot2_soft[1] = -0.08813666
dot2[2] = 0.00000000    dot2_soft[2] = 0.97706115

hw_error: i = 90 output = 2 t_test_num = 1
sw_error: i = 90 output_soft = 2 t_test_num = 1
dot2[0] = -5.00000000   dot2_soft[0] = -4.02276182
dot2[1] = 0.00000000    dot2_soft[1] = -0.66237617
dot2[2] = 0.00000000    dot2_soft[2] = 1.72938108

sw_error: i = 91 output_soft = 2 t_test_num = 1
dot2[0] = -5.00000000   dot2_soft[0] = -3.85103607
dot2[1] = 0.00000000    dot2_soft[1] = -0.09844255
dot2[2] = 0.00000000    dot2_soft[2] = 0.42963967

sw_error: i = 95 output_soft = 2 t_test_num = 1
dot2[0] = -6.00000000   dot2_soft[0] = -4.07760668
dot2[1] = 0.00000000    dot2_soft[1] = -0.30057180
dot2[2] = 0.00000000    dot2_soft[2] = 0.90393031

hw_err_cnt = 8 sw_err_cnt = 20
WARNING: Hls::stream 'hls::stream<ap_axiu<32, 1, 1, 1> >.1' contains leftover data, which may result in RTL simulation hanging.
INFO: [SIM 1] CSim done with 0 errors.
INFO: [SIM 3] *************** CSIM finish ***************


前にやった結果と同じなので、問題はないだろう。ちなみに 300 個やってハードウェアのエラーが 8 個、ソフトウェアのエラーが 20 個で、ハードウェアの正解確率は約 97 % 、ソフトウェアの正解確率は約 93 % だった。

次に、 C コードの合成を行った。
RTL_kernel_12_191228.png

レイテンシは max で 9176 クロックで 200 MHz なので、約 46 us かかっている。約 22,000 fps となる。

Export RTL を行った。Vivado synthesis, place and route にチェックを入れた。
RTL_kernel_13_191228.png

FF は 11.915 個だったが、合成時には、 15,866 個だったので、小さくなった。
LUT は 9,793 個とSRL の 550 個を足すと 10,343 個だったが、合成時には、 16, 774 個だった。

CP achieved post-implementation は 4.336 ns となっているので、問題はないだろう。

ip ディレクトリが作られ、kernel ディレクトリの下に kernel.xml が生成された。
RTL_kernel_16_191229.png

kernel.xml を示す。
RTL_kernel_15_191229.png

all_layers_dnn.xo が生成されている。
RTL_kernel_16_191229.png
  1. 2019年12月30日 04:00 |
  2. Vitis
  3. | トラックバック:0
  4. | コメント:0

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック URL
https://marsee101.blog.fc2.com/tb.php/4749-679383a7
この記事にトラックバックする(FC2ブログユーザー)