---
title: GetRequiredInputFormat
description: "根据算子原型定义中的输入索引获取对应的必选输入Format指针。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/maintenref/basicdataapi/atlasopapi_07_00574.html
sourcePath: /source/zh/canncommercial/900/maintenref/basicdataapi/atlasopapi_07_00574.html
indexId: 533c15ba200261f6c66cbc0379f6bee2ca519b2af4b62fbe0247e54949c15bd278
---
# 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);
  // ...
}
```
