<!--
{
  "availability" : [
    "iOS: 15.4.0 -",
    "iPadOS: 15.4.0 -",
    "macCatalyst: 15.4.0 -",
    "macOS: 12.3.0 -",
    "tvOS: 15.4.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/gatherAlongAxisTensor(_:updates:indices:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)gatherAlongAxisTensor:withUpdatesTensor:indicesTensor:name:"
  },
  "title" : "gatherAlongAxisTensor(_:updates:indices:name:)"
}
-->

# gatherAlongAxisTensor(_:updates:indices:name:)

Creates a GatherAlongAxis operation and returns the result tensor.

```
func gatherAlongAxisTensor(_ axisTensor: MPSGraphTensor, updates updatesTensor: MPSGraphTensor, indices indicesTensor: MPSGraphTensor, name: String?) -> MPSGraphTensor
```

## Parameters

`axisTensor`

Scalar Int32 tensor. The axis to gather from. Negative values wrap around

`updatesTensor`

The input tensor to gather values from

`indicesTensor`

Int32 or Int64 tensor used to index `updatesTensor`

`name`

The name for the operation.

## Return Value

A valid MPSGraphTensor object

## Discussion

Gather values from `updatesTensor` along the specified `axis` at indices in `indicesTensor`.
The shape of `updatesTensor` and `indicesTensor` must match except at `axis`.
The shape of the result tensor is equal to the shape of `indicesTensor`.
If an index is out of bounds of the `updatesTensor` along `axis` a 0 is inserted.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)