helion.language.rand#
- helion.language.rand(shape, seed, device=None)[source]#
hl.rand provides a Philox-based pseudorandom number generator (PRNG) that operates independently of PyTorch’s global random seed. Instead, it requires an explicit seed argument. Offsets are derived from the full logical sizes of the tiles specified in the shape argument.
- Parameters:
- Returns:
A device tensor of float32 dtype filled with uniform random values in [0, 1)
- Return type:
Examples
@helion.kernel def process_kernel(x: torch.Tensor) -> torch.Tensor: output = torch.zeros_like(x) (m,) = x.shape for tile_m in hl.tile(m): output[tile_m] = hl.rand([tile_m], seed=42) return output