| 18 | namespace tensorflow { |
| 19 | |
| 20 | void 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 | |
| 34 | void BFloat16ToFloat(const bfloat16* src, float* dst, int64 size) { |
| 35 | const uint16_t* p = reinterpret_cast<const uint16_t*>(src); |
no outgoing calls