---
title: "ClikaRT::ops::index_copy"
sidebar_label: "index_copy"
description: "A copy of input with rows of src WRITTEN at indices along dim: out[.., indices[i], ..] = src[.., i, ..]. Prefer unique indices; a duplicated position is written more than once."
---

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

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

## index\_copy() {#index_copy}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`index_copy`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int64_t` `dim`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `indices`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `src`<br />
)

</div>

A copy of `input` with rows of `src` WRITTEN at `indices` along `dim`: `out[.., indices[i], ..] = src[.., i, ..]`. Prefer unique indices; a duplicated position is written more than once.

Same shape/index-dtype rules as [`index_add`](./index_add.md#index_add).

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the shapes disagree or the index dtype is wrong (`code_name()` carries the reason).

**Returns:** a new tensor shaped like `input`.

<div class="api-declared">

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

</div>
