---
title: "ClikaRT::ops::put"
sidebar_label: "put"
description: "A copy of input with source written at FLAT (row-major linearized) positions: out.flat[index[i]] = source.flat[i]. With accumulate = true duplicate positions ADD instead of overwrite."
---

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

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

## put() {#put}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`put`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `index`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `source`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `accumulate` `=` `false`<br />
)

</div>

A copy of `input` with `source` written at FLAT (row-major linearized) positions: `out.flat[`[`index`](./index-fn.md#index)`[i]] = source.flat[i]`.

With `accumulate = true` duplicate positions ADD instead of overwrite. [`index`](./index-fn.md#index) and `source` carry the same element count; index dtype law as [`gather`](./gather.md#gather).

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the element counts differ, an index is out of range, or its 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 2630

</div>
