PromoteType

Description

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

ge::DataType PromoteType(ge::DataType type_a, ge::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;
    }
}