[LANGUAGE] Fixed issue with duplicates in large arrays of random uniform numbers (#338)

This commit is contained in:
Philippe Tillet
2021-10-10 15:22:34 -07:00
committed by GitHub
parent 9e9d781912
commit c3c0ff0552
2 changed files with 3 additions and 33 deletions

View File

@@ -100,11 +100,9 @@ def uint32_to_uniform_float(x):
This is originally designed from uint32, but it works with int32 too as long as the int32 uniformly
covers all the possible values it can take.
"""
mantissa = x & 0x7fffff
exp = 127
res = mantissa | (exp << 23)
return res.to(tl.float32, bitcast=True) - 1.0
max = 2147483647.
x = tl.where(x < 0, -x - 1, x)
return x / max
@triton.jit
def pair_uniform_to_normal(u1, u2):