ToBfloat16

Applicability

Product

Supported/Unsupported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product's AI Core

x

Atlas inference product's Vector Core

x

Atlas training products

x

Function Usage

Converts scalar data of the float type to scalar data of the bfloat16_t type.

Prototype

1
__aicore__ inline bfloat16_t ToBfloat16(const float& fVal)

Parameters

Table 1 API parameters

Parameter

Input/Output

Meaning

fVal

Input

Scalar data of the float type

Returns

Converted scalar data of the bfloat16_t type.

Restrictions

None

Example

1
2
float m = 3.0f;
bfloat16_t n = AscendC::ToBfloat16(m);