---
title: check_input_type
description: "装饰器函数，用于校验算子定义函数中的参数类型是否合法。"
url: https://www.hiascend.com/document/detail/zh/CANNCommunityEdition/latest/others/tbeaicpudevg/atlasoputilsapi_07_0008.html
sourcePath: /source/zh/CANNCommunityEdition/920beta1/others/tbeaicpudevg/atlasoputilsapi_07_0008.html
indexId: cc24d40d0118b8b4c3614b8f43ff2972590a0b2ad97a13f3173d86f26de0b2ca89
---
# check_input_type

#### 函数功能

装饰器函数，用于校验算子定义函数中的参数类型是否合法。


#### 函数原型

def check_input_type(*type_args, **type_kwargs)


#### 参数说明

| 参数 | 说明 |
| --- | --- |
| type\_args | 需要校验的参数类型列表，参数类型与算子定义函数的参数一一对应，其中： 算子的输入输出为字典类型。 字典格式中如果包含键值shape，则shape需要为元素组或者列表。 字典格式中如果包含键值dtype，则dtype需要为字符串类型。 其他参数请按照实际格式进行定义。 例如算子定义函数为： def add(input\_x, input\_y, output\_z, kernel\_name="add"): 使用此装饰器函数进行校验，则定义如下： @para\_check.check\_input\_type(dict,dict,dict,str) def add(input\_x, input\_y, output\_z, kernel\_name="add"): |
| type\_kwargs | 保留参数，暂不使用。 |


#### 返回值说明

无返回值。

如果输入参数校验失败，则抛RuntimeError。


#### 约束说明

无


#### 调用示例

```
from tbe.common.utils import para_check
@para_check.check_input_type(dict, int, str)
def
sample_op
(x, i, kernel_name):
sample_op({"shape":(32, 64, 64, 3),"dtype":"float16"}, "index", "sample_op")
```

检查sample_op的参数是否合法，由于参数“i”的类型不是int类型，会抛RuntimeError。
