函数:execute_with_handle
产品支持情况
- Ascend 950PR&950DT系列产品:不支持
- Atlas A3系列产品:支持
- Atlas A2系列产品:支持
- Atlas 200I/500 A2推理产品:支持
- Atlas推理系列产品:支持
- Atlas训练系列产品:支持
功能说明
以Handle方式调用一个算子,不支持动态Shape算子,动态Shape算子请使用acl.op.execute_v2。异步接口。
函数原型
-
C函数原型
aclError aclopExecWithHandle(aclopHandle *handle, int numInputs, const aclDataBuffer *const inputs[], int numOutputs, aclDataBuffer *const outputs[], aclrtStream stream) -
python函数
ret = acl.op.execute_with_handle(handle, inputs, outputs, stream)
参数说明
| 参数名 | 说明 |
|---|---|
| handle | int,指定执行算子的handle,指针地址。需提前调用acl.op.create_handle接口创建aclopHandle类型的数据。 |
| inputs | list,算子输入Tensor,整型列表,包含多个aclDataBuffer数据地址对象。需提前调用acl.create_data_buffer接口创建aclDataBuffer类型的数据。 |
| outputs | list,算子输出Tensor,整型列表,包含多个aclDataBuffer数据地址对象。需提前调用acl.create_data_buffer接口创建aclDataBuffer类型的数据。 |
| stream | int,执行算子所在的Stream,stream地址对象。 |
返回值说明
| 返回值 | 说明 |
|---|---|
| ret | int,错误码,返回0表示成功,返回其它值表示失败。 |
约束说明
-
该接口是异步接口,调用接口成功仅表示任务下发成功,不表示任务执行成功。调用该接口后,需调用同步等待接口(例如,
acl.rt.synchronize\_stream)确保任务已执行完成。 -
多线程场景下,不支持调用本接口时指定同一个Stream或使用默认Stream,否则可能任务执行异常。
-
执行有可选输入的算子时,如果可选输入不使用,则需参考以下方式创建aclDataBuffer类型的数据。
acl.create_data_buffer(nullptr, 0)
同时aclDataBuffer中的数据不需要释放,因为是空的数据类型。