---
title: 函数：execute_with_handle
description: "| 产品 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendgraphapi/aclpythondevg_01_0777.html
sourcePath: /source/zh/canncommercial/900/API/ascendgraphapi/aclpythondevg_01_0777.html
indexId: fbe88ce6f9ef0a171b344e8aa4d568c75a6d1c9aaaaaa4971dd39d9b3c4df62675
---
# 函数：execute_with_handle

#### 产品支持情况

| 产品 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | √ |
| Atlas A3 训练系列产品 / Atlas A3 推理系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 训练系列产品 | √ |
| Atlas 推理系列产品 | √ |
| Atlas 200I/500 A2 推理产品 | √ |


#### 功能说明

以Handle方式调用一个算子，不支持动态Shape算子，动态Shape算子请使用acl.op.execute_v2。异步接口。


#### 函数原型

- C函数原型
  1 aclError aclopExecWithHandle(aclopHandle *handle,int numInputs,const aclDataBuffer *const inputs[],int numOutputs,aclDataBuffer *const outputs[],aclrtStream stream);

- python函数
  1 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(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg\_01\_0016.html)接口创建aclDataBuffer类型的数据。 |
| outputs | list，算子输出Tensor，整形列表，包含多个aclDataBuffer数据地址对象。 需提前调用acl.create\_data\_buffer(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg\_01\_0016.html)接口创建aclDataBuffer类型的数据。 |
| stream | int，执行算子所在的Stream，stream地址对象。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| ret | int，错误码，返回0表示成功，返回其它值表示失败。 |


#### 约束说明

- 该接口是异步接口，调用接口成功仅表示任务下发成功，不表示任务执行成功。调用该接口后，需调用同步等待接口（例如，  acl.rt.synchronize_stream(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg_01_0087.html)
）确保任务已执行完成。

- 多线程场景下，不支持调用本接口时指定同一个Stream或使用默认Stream，否则可能任务执行异常。
- 执行有可选输入的算子时，如果可选输入不使用，则需参考以下方式创建aclDataBuffer类型的数据。

```
acl.create_data_buffer(nullptr, 0)
```


  同时aclDataBuffer中的数据不需要释放，因为是空的数据类型。
