TensorPlay
latest (dev)
Copy
View Markdown

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 0 to n - 1.

Parameters:

n (int) – the upper bound (exclusive)

Keyword Arguments:
  • generator (tensorplay.Generator, optional) – a pseudorandom number generator for sampling

  • out (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: if None, uses the current device for the default tensor type (see tensorplay.set_default_device()). device will 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])

On this page

Ask DeepWiki