MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / FloatToBFloat16

Function FloatToBFloat16

tensorflow/core/framework/bfloat16.cc:20–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18namespace tensorflow {
19
20void FloatToBFloat16(const float* src, bfloat16* dst, int64 size) {
21 const uint16_t* p = reinterpret_cast<const uint16_t*>(src);
22 uint16_t* q = reinterpret_cast<uint16_t*>(dst);
23#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
24 for (; size != 0; p += 2, q++, size--) {
25 *q = p[0];
26 }
27#else
28 for (; size != 0; p += 2, q++, size--) {
29 *q = p[1];
30 }
31#endif
32}
33
34void BFloat16ToFloat(const bfloat16* src, float* dst, int64 size) {
35 const uint16_t* p = reinterpret_cast<const uint16_t*>(src);

Callers 5

TESTFunction · 0.70
BM_FloatToBFloat16Function · 0.70
Proto2TensorFunction · 0.50
ComputeMethod · 0.50
ConvertToBF16ValueFunction · 0.50

Calls

no outgoing calls

Tested by 2

TESTFunction · 0.56
BM_FloatToBFloat16Function · 0.56