check_format

Description

Verifies the format of an operator.

Prototype

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

Parameters

Parameter

Description

data_format

Format.

check_list

Allowed format list.

Example: ["float16","int32"]

Defaults to ALL_FORMAT_LIST, which is defined as follows:

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

Parameter name, used as an additional prompt during message printing. Defaults to NULL.

Returns

None

If the verification fails, the following verification exception is thrown:

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

Alternatively,

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

Restrictions

None

Example

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

Checks whether the value of format is NCHW.