MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / round_to_bfloat16

Function round_to_bfloat16

src/framework/sampling/torch_random.cpp:146–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144 grid = std::max<uint64_t>(1, std::min(grid_cap, grid));
145 return block_size * grid;
146}
147
148float 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

Callers 2

fill_torch_cuda_randnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected