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

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

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

# gather

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

`gather(input: Tensor, dim: Long, index: Tensor)`: the `gather` operator. Axis-wise gather: read `input` at positions given by `index` along `dim`. `out[i][j][k] = x[index[i][j][k]][j][k]` for `dim = 0` (likewise for any other `dim`; only that axis's coordinate is replaced). The output takes `index`'s shape and `input`'s dtype. Index tensors are `Int32` or `Int64` on every backend; entries must lie in `[0, x`'s `dim` extent`)`.