利用 XRT C++ API 控制 AI 引擎 graph - 2022.1 简体中文

Versal ACAP AI 引擎编程环境 用户指南 (UG1076)

Document ID
UG1076
Release Date
2022-05-25
Version
2022.1 简体中文

如前一节中所述,XRT 可通过头文件 experimental/xrt_graph.h 提供 C 和 C++ API 来控制 AI 引擎 graph。

XRT 在名称空间 xrt 及其成员函数内提供 graph 类,以控制 graph。以下提供了使用 XRT C++ API 来控制 AI 引擎 graph 的代码示例:

using namespace adf;
// Open xclbin
auto device = xrt::device(0); //device index=0
auto uuid = device.load_xclbin(xclbinFilename);
auto dhdl = xrtDeviceOpenFromXcl(device);
...
int coeffs_readback[12];
int narrow_filter[12] = {180, 89, -80, -391, -720, -834, -478, 505, 2063, 3896, 5535, 6504};
int wide_filter[12] = {-21, -249, 319, -78, -511, 977, -610, -844, 2574, -2754, -1066, 18539};
auto ghdl=xrt::graph(device,uuid,"gr");
ghdl.update("gr.fir24.in[1]",narrow_filter);
ghdl.run(16);
ghdl.wait();
ghdl.read("gr.fir24.inout[0]",coeffs_readback);//Read after graph::wait. RTP update effective
ghdl.update("gr.fir24.in[1]",wide_filter);
ghdl.run(16);
ghdl.read("gr.fir24.inout[0]", coeffs_readback);//Async read
ghdl.end();
注释: Work/ps/c_rts/aie_control_xrt.cpp 文件包含有关 graph、RTP、GMIO 和初始化配置的信息。例如,在以上代码中,您可在 aie_control_xrt.cppRTP Configurations 部分中找到 RTP 端口名称,名为 gr.fir24.in[1]