Cast (float to bfloat16_t)
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function Usage
Converts scalar data of the float type to scalar data of the bfloat16_t type.
Prototype
1 | __aicore__ inline bfloat16_t Cast(const float& fVal) |
Parameters
Parameter |
Input/Output |
Meaning |
|---|---|---|
fVal |
Input |
Scalar data of the float type. |
Returns
Converted scalar data of the bfloat16_t type.
Constraints
None
Example
1 2 | float m = 3.0f; bfloat16_t n = AscendC::Cast(m); // n = 3.0. The exponent and mantissa expressions of bfloat16_t and float are different. Truncation can be used for conversion. |
Parent topic: Scalar Computation