异步运行指定id对应的Graph图,输出运行结果。
此函数与RunGraph均为执行指定id对应的图,并输出结果,区别于RunGraph的是,该接口:
1 2 | Status RunGraphAsync(uint32_t graph_id, const std::vector<ge::Tensor> &inputs, RunAsyncCallback callback) Status RunGraphAsync(uint32_t graph_id, const ContinuousTensorList &inputs, RunAsyncCallback callback) |
参数名 |
输入/输出 |
描述 |
||
---|---|---|---|---|
graph_id |
输入 |
子图对应的id。 |
||
inputs |
输入 |
当前子图对应的输入数据。
|
||
callback |
输出 |
当前子图对应的回调函数。
|
参数名 |
类型 |
描述 |
---|---|---|
- |
Status |
GE_CLI_GE_NOT_INITIALIZED:GE未初始化。 SUCCESS:异步运行图成功。 FAILED:异步运行图失败。 |
无。
1 2 3 4 5 6 | std::map <AscendString, AscendString> options; ge::Session *session = new Session(options); uint32_t graph_id = 0; ge::Graph graph; Status ret = session->AddGraph(graph_id, graph); |
1 2 3 4 5 6 7 8 9 | void CallBack(Status result, std::vector<ge::Tensor> &out_tensor) { if(result == ge::SUCCESS) { // 读取out_tensor数据, 用户根据需求处理数据; for(auto &tensor : out_tensor) { auto data = tensor.GetData(); int64_t length = tensor.GetSize(); } } } |