---
title: "ClikaRT::ops::permute"
sidebar_label: "permute"
description: "Reorder the dims by dims, a permutation of [0, rank). Returns a VIEW (metadata only, no copy). A kernel that later needs dense data materializes internally; no contiguous call is needed here."
---

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

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

## permute() {#permute}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`permute`**([`Tensor`](../Tensor.md) `input`, [`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dims`)

</div>

Reorder the dims by `dims`, a permutation of `[0, rank)`.

Returns a VIEW (metadata only, no copy). A kernel that later needs dense data materializes internally; no [`contiguous`](./contiguous.md#contiguous) call is needed here.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `dims` is not a permutation of the input's dims (`code_name()` carries the reason).

**Returns:** a view of `input` with reordered dims.

```cpp
auto nhwc = ClikaRT::ops::permute(nchw, {0, 2, 3, 1});  // no copy
```

<div class="api-declared">

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

</div>
