PromoteType

Function Usage

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

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 calculation fails and DT_UNDEFINED is returned.

Constraints

None

Example

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 (PomoteType(dtype, DT_FLOAT) == DT_UNDEFINED) {
        return;
    }
}