---
title: "ClikaRT::ops::index_fill"
sidebar_label: "index_fill"
description: "A copy of input with the rows at indices along dim set to value: out[.., indices[i], ..] = value. indices is 1-D Int32/Int64; value is a literal or a 0-D Tensor."
---

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

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

## index\_fill() {#index_fill}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`index_fill`**(<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;[`ScalarOrTensor`](../ScalarOrTensor.md) `value`<br />
)

</div>

A copy of `input` with the rows at `indices` along `dim` set to `value`: `out[.., indices[i], ..] = value`.

`indices` is 1-D `Int32`/`Int64`; `value` is a literal or a 0-D [Tensor](../Tensor.md).

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `dim` is out of range 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 2552

</div>
