---
title: SetInferShape
description: "使用图模式时，需要调用该接口注册Shape推导函数。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendcopapi/atlasascendc_api_07_0950.html
sourcePath: /source/zh/canncommercial/900/API/ascendcopapi/atlasascendc_api_07_0950.html
indexId: d97f720746f9e9e5b073be0ff0e7862df6d139e28d0d412546f74b6b87e32e5c76
---
# SetInferShape

#### 功能说明

使用图模式时，需要调用该接口注册Shape推导函数。


#### 函数原型

```
OpDef &SetInferShape(gert::OpImplRegisterV2::InferShapeKernelFunc func)
```


#### 参数说明

| 参数 | 输入/输出 | 说明 |  |  |
| --- | --- | --- | --- | --- |
| func | 输入 | Shape推导函数。InferShapeKernelFunc类型定义如下，入参类型参考InferShapeContext(https://www.hiascend.comdocument/detail/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi\_07\_00094.html)： 1 using InferShapeKernelFunc = UINT32 (\*)(InferShapeContext \*); | 1 | using InferShapeKernelFunc = UINT32 (\*)(InferShapeContext \*); |
| 1 | using InferShapeKernelFunc = UINT32 (\*)(InferShapeContext \*); |  |  |  |


#### 返回值说明

OpDef算子定义，OpDef请参考OpDef。


#### 约束说明

无
