下载
中文
注册

check_format

函数功能

对算子的Format进行校验。

函数原型

def check_format(data_format, check_list=None, param_name=PARAM_NAME)

参数说明

参数

说明

data_format

数据Format。

check_list

支持的Format检查列表。

需要使用列表形式,例如:["float16","int32"]

默认值为ALL_FORMAT_LIST,ALL_FORMAT_LIST的定义如下:

ALL_FORMAT_LIST = ("ND","NCHW","NHWC","NDHWC","NCDHW","CHWN","NC1HWC0","NC1HWC0_C04","NDC1HWC0","FRACTAL_NZ","HWCN","DHWCN","FRACTAL_Z","FRACTAL_Z_C04","C1HWNCoC0","FRACTAL_Z_3D","FRACTAL_ZN_LSTM")

param_name

参数名称,用于打印信息时辅助提示,默认值为NULL。

返回值说明

无返回值。

若校验失败,则抛出如下校验异常:

RuntimeError:"In op, the input[%s]'s format could not be none"

RuntimeError:"In op, the format of input[%s] should be one of [%s], but actually is [%s]."

约束说明

调用示例

from tbe.common.utils import para_check 
para_check.check_format("NCHW") 

检查format为"NCHW"是否正确。