---
title: "ClikaRT::ops::index_add"
sidebar_label: "index_add"
description: "A copy of input with rows of src ACCUMULATED at indices along dim: out[.., indices[i], ..] += src[.., i, ..]; duplicate indices add up. input the starting values. dim the addressed axis."
---

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

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

## index\_add() {#index_add}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`index_add`**(<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` ACCUMULATED at `indices` along `dim`: `out[.., indices[i], ..] += src[.., i, ..]`; duplicate indices add up.

**Parameters**

- `input`: the starting values.
- `dim`: the addressed axis.
- `indices`: 1-D integer positions (`Int32`/`Int64`).
- `src`: the rows to add; its `dim` extent equals `indices`' length, every other extent matches `input`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the shapes disagree per the rule above 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 2525

</div>
