| 197 | } |
| 198 | |
| 199 | uint16_t f32_to_bf16(float x) { |
| 200 | uint32_t u; |
| 201 | std::memcpy(&u, &x, 4); |
| 202 | return (uint16_t) ((u + 0x7fffu + ((u >> 16) & 1u)) >> 16); |
| 203 | } |
| 204 | |
| 205 | // an F32 tensor's first n values, read on the host |
| 206 | const float* f32_data(const Tensor& t, size_t n) { |