MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / random_u32

Function random_u32

experimental/kernels/gpt2_webgpu.cpp:626–632  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624// sampler
625
626unsigned int random_u32(uint64_t *state) {
627 // xorshift rng: https://en.wikipedia.org/wiki/Xorshift#xorshift.2A
628 *state ^= *state >> 12;
629 *state ^= *state << 25;
630 *state ^= *state >> 27;
631 return (*state * 0x2545F4914F6CDD1Dull) >> 32;
632}
633float random_f32(uint64_t *state) { // random float32 in [0,1)
634 return (random_u32(state) >> 8) / 16777216.0f;
635}

Callers 1

random_f32Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected