更新时间:2021-03-18 GMT+08:00
分享

Graph::SetDataRecvFunctor

设置Graph中某Engine接收消息的回调函数。调用该接口的代码的运行环境必须与Engine一致,例如,Engine在Device侧运行,那么调用该函数的代码也必须运行在Device。该接口在graph.h中定义。

该接口需要与DataRecvInterface::RecvData接口配合使用,一般用于将推理结果返回给用户,详细原理如下:

  1. 定义一个DataRecvInterface类的子类(例如DdkDataRecvInterface),初始化一个子类的对象。
  2. 调用Graph::SetDataRecvFunctor接口将DdkDataRecvInterface类的对象设置成回调函数。
  3. 调用Engine::SendData函数将对应的输入数据发送到对应的输出端口。
  4. 调用DdkDataRecvInterface类的RecvData函数返回推理结果。

函数格式

static HIAI_StatusT Graph::SetDataRecvFunctor(const EnginePortID& targetPortConfig, const std::shared_ptr<DataRecvInterface>& dataRecv);

参数说明

参数

说明

取值范围

targetPortConfig

数据接收方的Graph ID、Engine ID 和Port ID。

-

dataRecv

用户自定义的数据接收回调函数。

-

返回值

返回的部分错误码请参见“错误码示例”中的“错误码”列。

错误码示例

序号

错误码

错误码描述

1

HIAI_OK

running ok

2

HIAI_PORT_ID_ERROR

port id error

分享:

    相关文档

    相关产品