---
title: "ClikaRT::ops::scatter_reduce"
sidebar_label: "scatter_reduce"
description: "scatter with a REDUCTION at each destination: Sum / Prod / Mean / AMax / AMin (ScatterReduceMode). reduce the reduction applied where writes collide."
---

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

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

## scatter\_reduce() {#scatter_reduce}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`scatter_reduce`**(<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) `index`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `src`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ScatterReduceMode`](./index.md#ScatterReduceMode) `reduce`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `include_self` `=` `true`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `deterministic` `=` `false`<br />
)

</div>

[`scatter`](./scatter.md#scatter) with a REDUCTION at each destination: `Sum` / `Prod` / `Mean` / `AMax` / `AMin` ([`ScatterReduceMode`](./index.md#ScatterReduceMode)).

**Parameters**

- `reduce`: the reduction applied where writes collide.
- `include_self`: true (default) folds the destination's own starting value into the reduction; false reduces the scattered values alone.
- `deterministic`: as [`scatter_add`](./scatter_add.md#scatter_add). Default `false`.

**Throws**

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

</div>
