[XLA] Don't return 1 for a random floating point in range [0, 1).
The old implementation of this routine was converting a u32 I to a random f32 F in range by doing uint32 I; float F = static_cast<float>(I) / static_cast<float>(2^32); But this will return 1 if that's the closest float to I / 2^32, and we want a float in range [0, 1), not [0, 1]. This is significant particularly for normally-distributed random numbers, because in that case we end up computing erfinv(1) = inf and causing infinities to appear in our normal distribution. Instead, we manually construct a floating-point value. Also fix the interpreter in the same way and add a comment to HloInstruction::CreateRng. PiperOrigin-RevId: 233874065
Loading
Please sign in to comment