Truncate a float to bf16 precision. * * @param[in] v F32 value to truncate to bfloat16 precision * * @return Truncated float */
| 82 | * @return Truncated float |
| 83 | */ |
| 84 | inline float to_bf_precision(float v) |
| 85 | { |
| 86 | uint32_t resu32 = ((uint32_t)(float_to_bf16(v)) << 16); |
| 87 | float resf32; |
| 88 | memcpy(&resf32, &resu32, sizeof resf32); |
| 89 | return resf32; |
| 90 | } |
| 91 | |
| 92 | /** Convert bfloat16 to float |
| 93 | * |