---
title: GetRequiredInputFormat
description: "根据算子原型定义中的输入索引获取对应的必选输入Format指针。"
url: https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/latest/maintenref/basicdataapi/atlasopapi_07_00574.html
sourcePath: /source/zh/CANNCommunityEdition/920beta1/maintenref/basicdataapi/atlasopapi_07_00574.html
indexId: 82bd4af597172b210ae2585fa6379353e2c5d1da644a4955299f5042534efc8d89
---
# GetRequiredInputFormat

#### 函数功能

根据算子原型定义中的输入索引获取对应的必选输入Format指针。


#### 函数原型

```
StorageFormat *GetRequiredInputFormat(const size_t ir_index)
```


#### 参数说明

| 参数 | 输入/输出 | 说明 |
| --- | --- | --- |
| ir\_index | 输入 | IR原型定义中的索引，从0开始计数。 |


#### 返回值说明

输入Format指针，ir_index非法时，返回空指针。

关于StorageFormat类型的定义，请参见StorageFormat。


#### 约束说明

无。


#### 调用示例

```
ge::graphStatus InferFormatForXXX(InferFormatContext *context) {
  auto format = context->GetRequiredInputFormat(0);        // 获取第0个输入的format
  GE_ASSERT_NOTNULL(format);
  // ...
}
```
