check_dtype_rule

Description

Verifies the data type of a tensor.

Verifies the data type by looking up the allowed check_list. If the verification fails, the message "RuntimeError" is thrown.

Prototype

def check_dtype_rule(dtype, check_list, param_name="default")

Parameters

Parameter

Description

dtype

Data type to check.

It is a string and must not be left empty.

check_list

Data type check list.

It is a list of strings.

param_name

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

Returns

None

"RuntimeError" is thrown if the verification fails.

Restrictions

None

Example

from tbe.common.utils import para_check 
para_check.check_dtype_rule("float64", ["float16","float32"], "a") 

This example is used to verify the data type of a. "RuntimeError" is thrown as the verification fails.