latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.functional.randperm
- tensorplay.functional.randperm(n, *, generator=None, out=None, dtype=tensorplay.int64, layout=tensorplay.strided, device=None, requires_grad=False, pin_memory=False) Tensor[source]
Returns a random permutation of integers from
0ton - 1.- Parameters:
n (int) – the upper bound (exclusive)
- Keyword Arguments:
generator (
tensorplay.Generator, optional) – a pseudorandom number generator for samplingout (Tensor, optional) – the output tensor.
dtype (
tensorplay.dtype, optional) – the desired data type of returned tensor. Default:tensorplay.int64.layout (
tensorplay.layout, optional) – the desired layout of returned Tensor. Default:tensorplay.strided.device (
tensorplay.device, optional) – the desired device of returned tensor. Default: ifNone, uses the current device for the default tensor type (seetensorplay.set_default_device()).devicewill be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.requires_grad (bool, optional) – If autograd should record operations on the returned tensor. Default:
False.pin_memory (bool, optional) – If set, returned tensor would be allocated in the pinned memory. Works only for CPU tensors. Default:
False.
Example:
>>> tensorplay.randperm(4) tensor([2, 1, 0, 3])
Help improve this page
Found an error, an unclear step, or a missing example?

