---
title: "ClikaRT::ops::randperm"
sidebar_label: "randperm"
description: "A random permutation of the integers 0 .. n-1. n the permutation length (scalar or 0-D tensor). dtype output integer dtype; default Int64. device stream or device; default = the default device."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## randperm() {#randperm}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`randperm`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScalarOrTensor`](../ScalarOrTensor.md) `n`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`DataType`](../../index.md#DataType) `dtype` `=` [`DataType::Int64`](../../index.md#DataType),<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`StreamOrDevice`](../StreamOrDevice.md) `device` `=` `{}`<br />
)

</div>

A random permutation of the integers `0 .. n-1`.

**Parameters**

- `n`: the permutation length (scalar or 0-D tensor).
- `dtype`: output integer dtype; default `Int64`.
- `device`: stream or device; default = the default device.

**Returns:** a 1-D tensor of length `n` holding each index exactly once.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on a negative `n`.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 4250

</div>
