| 144 | grid = std::max<uint64_t>(1, std::min(grid_cap, grid)); |
| 145 | return block_size * grid; |
| 146 | } |
| 147 | |
| 148 | float round_to_bfloat16(float value) { |
| 149 | uint32_t bits = 0; |
| 150 | static_assert(sizeof(bits) == sizeof(value)); |
| 151 | std::memcpy(&bits, &value, sizeof(bits)); |
| 152 | bits += 0x7FFFU + ((bits >> 16U) & 1U); |
| 153 | bits &= 0xFFFF0000U; |
| 154 | float rounded = 0.0F; |
| 155 | std::memcpy(&rounded, &bits, sizeof(rounded)); |
| 156 | return rounded; |
| 157 | } |
| 158 |
no outgoing calls
no test coverage detected