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

#### 产品支持情况

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


#### 功能说明

创建一个执行算子的handle。

如需销毁handle，请参见acl.op.destroy_handle。


#### 函数原型

- C函数原型
  1 aclError aclopCreateHandle(const char *opType, int numInputs,int numInputs, const aclTensorDesc *const inputDesc[], int numOutputs, const aclTensorDesc *const outputDesc[], const aclopAttr *opAttr, aclopHandle **handle)

- python函数
  1 handle, ret = acl.op.create_handle(op_type, input_desc, output_desc, op_attr)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| op\_type | str，指定算子类型名称字符串类型。 |
| input\_desc | list，算子输入Tensor的描述，整形列表。 |
| output\_desc | list，算子输出Tensor的描述，整形列表。 |
| op\_attr | int，算子属性指针地址，此对象使用调用acl.op.create\_attr创建。 |


#### 返回值说明

| 返回值 | 说明 |
| --- | --- |
| handle | int，算子handle地址对象。 |
| ret | int，错误码。 返回0表示成功。 返回其它值(https://www.hiascend.comdocument/detail/zh/canncommercial/900/API/runtimeapi/aclpythondevg\_01\_0911.html)表示失败。 |


#### 约束说明

对于算子有constant输入的场景，如果未调用acl.set_tensor_const接口设置constant输入，则需调用acl.set_tensor_place_ment设置TensorDesc的placement属性，将“mem_type”设置为Host内存。
