torch.func._random.bits_#
- torch.func._random.bits_(key, result)[source]#
Fill
resultin-place with raw random bits from a PRNG key.Equivalent to
randint_()over the full range ofresult’s dtype. That range is a power of two, so unlike a bounded draw this is exactly uniform. Signed dtypes receive negative values as well.Supports batched keys: if
keyhas shape(*batch, K), the leading dimensions ofresultmust be broadcastable with*batchand each key independently generates its slice of the output.- Parameters:
- Returns:
result, filled with raw random bits.- Return type:
Example:
>>> key = torch.func._random.key(42, device="cuda") >>> result = torch.empty(1000, dtype=torch.uint32, device="cuda") >>> torch.func._random.bits_(key, result)