---
title: "scatter"
sidebar_label: "scatter"
description: "Kotlin binding reference: scatter."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Ops](index.md)/[scatter](scatter.md)

# scatter

[common]\
fun [scatter](scatter.md)(input: [Tensor](../Tensor/index.md), dim: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html), index: [Tensor](../Tensor/index.md), src: [Tensor](../Tensor/index.md)): [Tensor](../Tensor/index.md)

`scatter(input: Tensor, dim: Long, index: Tensor, src: Tensor)`: the `scatter` operator. A copy of `input` with `src` written at positions given by `index` along `dim`, the write mirror of `gather`: `out[index[p]][j][k] = src[p]` for `dim = 0` (only that axis's coordinate is redirected). A scalar `src` broadcasts one value to every indexed position; a tensor `src` matches `index`'s shape. On duplicate destinations one write wins; use `scatter_add` / `scatter_reduce` for well-defined accumulation. Index dtype law as `gather`.

[common]\
fun [scatter](scatter.md)(input: [Tensor](../Tensor/index.md), dim: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html), index: [Tensor](../Tensor/index.md), src: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)): [Tensor](../Tensor/index.md)

`scatter(input: Tensor, dim: Long, index: Tensor, src: Double)`: the number form of `scatter`, `src` as a scalar.