check_input_type
函数功能
装饰器函数,用于校验算子定义函数中的参数类型是否合法。
函数原型
def check_input_type(*type_args, **type_kwargs)
参数说明
参数  | 
        说明  | 
       
|---|---|
type_args  | 
        
          
          需要校验的参数类型列表,参数类型与算子定义函数的参数一一对应,其中:
          
           例如算子定义函数为: 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。
     父主题: 算子参数校验