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

#### 产品支持情况

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


#### 功能说明

动态Shape场景下，注册算子选择器，用于在算子执行时，能针对不同shape，选择相应的Tiling策略。

如果某算子已注册算子选择器，则不允许重新注册，如果需要变更算子选择器，必须先调用acl.op.unregister_compile_func接口取消注册，然后再调用acl.op.register_compile_func接口重新注册。


#### 函数原型

- C函数原型
  1 aclError aclopRegisterCompileFunc(const char *opType, aclopCompileFunc func)

- python函数
  1 ret = acl.op.register_compile_func(op_type, func)


#### 参数说明

| 参数名 | 说明 |
| --- | --- |
| op\_type | str，算子类型。 |
| func | python函数对象，算子选择器回调函数，函数定义： Python侧格式如下： def call\_back\_func(num\_inputs, input\_desc, num\_outputs, output\_desc, op\_attr, aclop\_kernel\_desc): pass |


#### 返回值说明

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


#### 资源参考

接口调用流程、示例，参见单算子调用(https://www.hiascend.comdocument/detail/zh/canncommercial/900/programug/acldevg/aclpythondevg_0066.html)。
