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

#### 产品支持情况

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


#### 功能说明

动态Shape场景下，将算子注册到系统内部，运行算子时使用。


#### 函数原型

- C函数原型
  1 2 3 4 5 6 7 aclError aclopCreateKernel(const char *opType, const char *kernelId, const char *kernelName, void *binData, int binSize, aclopEngineType enginetype, aclDataDeallocator deallocator)

- python函数
  1 ret = acl.op.create_kernel(op_type, kernel_id, kernel_name, bin_data, bin_size, enginetype, deallocator)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| op\_type | str，算子类型。 |
| kernel\_id | str，算子执行时要指定的Kernel ID。 |
| kernel\_name | str，算子Kernel名称，和算子二进制文件中的kernelName保持一致。 |
| bin\_data | int，算子Kernel文件的内存地址。 |
| bin\_size | int，算子Kernel文件的内存大小，单位为Byte。 |
| enginetype | int，表示算子执行引擎，该参数只有acl.op.update.params接口的“compile\_flag”参数值为“ACL\_COMPILE\_SYS”时有效。 0：ACL\_ENGINE\_SYS，不关心具体执行引擎时填写。 1：ACL\_ENGINE\_AICORE，将算子编译成AI Core算子。 2：ACL\_ENGINE\_VECTOR，将算子编译成Vector Core算子。 |
| deallocator | int，指定是否自动释放bin\_data内存。 0：不自动释放，数据由调用者自行编写代码进行释放。 1：自动释放，内部会设置回调函数释放bin\_data内存。 |


#### 返回值说明

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