# tensorflow::ops::Gather Class Reference

# tensorflow::
ops::
Gather

`
#include <array_ops.h>
`


[Gather](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather)
slices from
`
params
`
according to
`
indices
`
.

## Summary


`
indices
`
must be an integer tensor of any dimension (usually 0-D or 1-D). Produces an output tensor with shape
`
indices.shape + params.shape[1:]
`
where:


```
    # Scalar indices
    output[:, ..., :] = params[indices, :, ... :]
```

<br />


```
    # Vector indices
    output[i, :, ..., :] = params[indices[i], :, ... :]
```

<br />


```
    # Higher rank indices
    output[i, ..., j, :, ... :] = params[indices[i, ..., j], :, ..., :]
```

<br />


If
`
indices
`
is a permutation and
`
len(indices) == params.shape[0]
`
then this operation will permute
`
params
`
accordingly.


`
validate_indices
`
: DEPRECATED. If this operation is assigned to CPU, values in
`
indices
`
are always validated to be within range. If assigned to GPU, out-of-bound indices result in safe but unspecified behavior, which may include raising an error.


![](https://www.tensorflow.org/static/versions/r2.6/api_docs/cc/images/Gather.png)

<br />


Args:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object

<br />


Returns:

- `
  https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output
  ` : The output tensor.

<br />

| ### Constructors and Destructors ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather_1a839275b14b2a970a2bdaafee039469dd (const :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input params, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input indices) ` ||
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather_1aafacd8f95dd561da28cb61d32a6a315f (const :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input params, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input indices, const https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/gather/attrs#structtensorflow_1_1ops_1_1_gather_1_1_attrs & attrs) ` ||

| ### Public attributes ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather_1a324a25a3a94bb8ec9ea1f0c18e864f7d ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather_1a9d78b5b304387efee0e53b5afaa384ef ` | ` :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output ` |

| ### Public functions ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather_1a6861dab37fe274f230029422bd94b724 () const ` | ` ::tensorflow::Node * ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather_1a8ea808391c4824b35409a4427fcfd5eb () const ` | ` ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather_1a3dfd72e34f22afeaad6918d75a6cfdcd () const ` | ` ` |

| ### Public static functions ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather_1acb10767dcd5da7c1d454b97feafe2f3b (bool x) ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/gather/attrs#structtensorflow_1_1ops_1_1_gather_1_1_attrs ` |

| ### Structs ||
|---|---|
| [tensorflow:: ops:: Gather:: Attrs](https://www.tensorflow.org/versions/r2.6/api_docs/cc/struct/tensorflow/ops/gather/attrs) | Optional attribute setters for [Gather](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/gather#classtensorflow_1_1ops_1_1_gather) . |

## Public attributes

### operation

```
Operation operation
```

### output

```
::tensorflow::Output output
```

## Public functions

### Gather

```
 Gather(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input params,
  ::tensorflow::Input indices
)
```

### Gather

```
 Gather(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input params,
  ::tensorflow::Input indices,
  const Gather::Attrs & attrs
)
```

### node

```
::tensorflow::Node * node() const 
```

### operator::tensorflow::Input

```
 operator::tensorflow::Input() const 
```

### operator::tensorflow::Output

```
 operator::tensorflow::Output() const 
```

## Public static functions

### ValidateIndices

```
Attrs ValidateIndices(
  bool x
)
```