PromoteType

Function Usage

Promotes the data type to a specified type for computation in the case of different data types. For example, if float16 and float32 are used for computation, float16 must be promoted to float32 before computation.

Prototype

DataType PromoteType(const DataType type_a, const DataType type_b)

Parameters

Parameter

Input/Output

Description

type_a

Input

Data type of the first parameter.

type_b

Input

Data type of the second parameter.

Returns

If the promoted data type cannot be derived, the computation fails and DT_UNDEFINED is returned.

Constraints

None

Examples

1
2
3
4
5
6
// Check whether dtype can be computed together with float32. If not, a return statement is executed.
void Func(const DataType dtype) {
    if (PromoteType(dtype, DT_FLOAT) == DT_UNDEFINED) {
        return;
    }
}