MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / float_to_bf16

Function float_to_bf16

support/Bfloat16.h:60–76  ·  view source on GitHub ↗

Convert float to bfloat16 * * @param[in] v Floating-point value to convert to bfloat * * @return Converted value */

Source from the content-addressed store, hash-verified

58 * @return Converted value
59 */
60inline uint16_t float_to_bf16(const float v)
61{
62#if defined(ARM_COMPUTE_ENABLE_BF16)
63 const uint32_t *fromptr = reinterpret_cast<const uint32_t *>(&v);
64 uint16_t res;
65
66 __asm __volatile("ldr s0, [%[fromptr]]\n"
67 ".inst 0x1e634000\n" // BFCVT h0, s0
68 "str h0, [%[toptr]]\n"
69 :
70 : [fromptr] "r"(fromptr), [toptr] "r"(&res)
71 : "v0", "memory");
72 return res;
73#else /* defined(ARM_COMPUTE_ENABLE_BF16) */
74 return portable_float_to_bf16(v);
75#endif /* defined(ARM_COMPUTE_ENABLE_BF16) */
76}
77
78/** Truncate a float to bf16 precision.
79 *

Callers 4

exponential_bf16Function · 0.85
to_bf_precisionFunction · 0.85
bfloat16Method · 0.85
bfloat16Class · 0.85

Calls 1

portable_float_to_bf16Function · 0.85

Tested by

no test coverage detected