<!--
{
  "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/scatterAlongAxis(_:updates:indices:shape:mode:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)scatterAlongAxis:withUpdatesTensor:indicesTensor:shape:mode:name:"
  },
  "title" : "scatterAlongAxis(_:updates:indices:shape:mode:name:)"
}
-->

# scatterAlongAxis(_:updates:indices:shape:mode:name:)

Creates a ScatterAlongAxis operation and returns the result tensor.

```
func scatterAlongAxis(_ axis: Int, updates updatesTensor: MPSGraphTensor, indices indicesTensor: MPSGraphTensor, shape: [NSNumber], mode: MPSGraphScatterMode, name: String?) -> MPSGraphTensor
```

## Parameters

`axis`

The axis to scatter to. Negative values wrap around

`updatesTensor`

The input tensor to scatter values from

`indicesTensor`

Int32 or Int64 tensor used to index the result tensor.

`mode`

The type of update to use

`name`

The name for the operation.

## Return Value

A valid MPSGraphTensor object

## Discussion

Scatter values from `updatesTensor` along the specified `axis` at indices in `indicesTensor` into a result tensor.
Values are updated following `mode`. See MPSGraphScatterMode.
The shape of `updatesTensor` and `indicesTensor` must match. `shape` must match except at `axis`.
The shape of the result tensor is equal to `shape` and initialized with an initial value corresponding to `mode`.
If an index is out of bounds of `shape` along `axis` the update value is skipped.

---

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)