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

#### 产品支持情况

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


#### 功能说明

启动对应Kernel的计算任务。仅支持Ascend C自定义算子。


#### 函数原型

- C函数原型
  1 aclError aclrtLaunchKernel(aclrtFuncHandle funcHandle, uint32_t numBlocks, const void *argsData, size_t argsSize, aclrtStream stream)

- python函数
  1 ret = acl.rt.launch_kernel(func_handle, num_blocks, args_data, args_size, stream)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| func\_handle | int，调用acl.rt.binary\_get\_function接口根据kernel\_name获取func\_handle。 |
| num\_blocks | int，指定核函数将会在几个核上执行。 |
| args\_data | int，存放Kernel所有入参数据的Device内存地址指针。内存申请接口请参见内存管理。 |
| args\_size | int，argsData参数值的大小，单位为Byte。 |
| stream | int，指定执行任务的Stream，可复用已创建的Stream节省资源或调用acl.rt.create\_stream接口创建Stream，再作为入参在此处传入。 |


#### 返回值说明

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


#### 约束说明

该接口是异步接口，调用接口成功仅表示任务下发成功，不表示任务执行成功。调用该接口后，需调用同步等待接口（例如，acl.rt.synchronize_stream）确保任务已执行完成。
