graph 的有限执行 - 2022.1 简体中文

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

Document ID
UG1076
Release Date
2022-05-25
Version
2022.1 简体中文
对于有限 graph 执行,graph 状态在 graph.run(n) 整个执行过程中保持不变。完成 graph.run(n) 后,AI 引擎无需重新初始化,也不会清除存储器内容。在以下代码示例中,完成三次迭代的首轮运行后,AI 引擎 main() 封装文件代码会保留在相应状态下,使内核在下一轮运行中仍将以乒乓缓冲器启动。乒乓缓冲器选择器状态按现状保持不变。graph.end() 并不会清除 graph 状态(具体来说,不会重新初始化全局变量),也不会清除串流交换机配置。它仅退出 core-main。要重新运行 graph,您必须重新加载 PDI/XCLBIN。
重要: graph.wait() 必须后接 graph.run()graph.resume(),而后才能执行 graph.end()。否则,graph 可能永久等待,并且永不执行 graph.end()。请参阅 graph 对象,了解有关使用这些 API 的更多详细信息。
#include "project.h" 
simpleGraph mygraph; 

int main(void) { 
  mygraph.init(); 
  mygraph.run(3); // run 3 iterations 
  mygraph.wait(); // wait for 3 iterations to finish 
  mygraph.run(10); // run 10 iterations 
  mygraph.end(); // wait for 10 iterations to finish 
  return 0; 
}