---
title: "ClikaRT::ops::masked_scatter"
sidebar_label: "masked_scatter"
description: "A copy of input with the leading count(mask) elements of src (read row-major) written at the positions where mask is true."
---

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

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

## masked\_scatter() {#masked_scatter}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`masked_scatter`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `mask`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `source`<br />
)

</div>

A copy of `input` with the leading `count(mask)` elements of `src` (read row-major) written at the positions where `mask` is true.

`mask` is Bool, broadcastable to `input`; `src` must supply at least `count(mask)` elements.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `src` is too short or `mask` is not Bool (`code_name()` carries the reason).

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

<div class="api-declared">

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

</div>
