---
title: "scatterND(withUpdatesTensor:indicesTensor:shape:batchDimensions:mode:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/scatternd(withupdatestensor:indicestensor:shape:batchdimensions:mode:name:)"
---

# scatterND(withUpdatesTensor:indicesTensor:shape:batchDimensions:mode:name:)

Creates a ScatterND operation and returns the result tensor.

## Declaration

```swift
func scatterND(withUpdatesTensor updatesTensor: MPSGraphTensor, indicesTensor: MPSGraphTensor, shape: [NSNumber], batchDimensions: Int, mode: MPSGraphScatterMode, name: String?) -> MPSGraphTensor
```

## Parameters

- `updatesTensor`: Tensor containing slices to be inserted into the result tensor.
- `indicesTensor`: Tensor containg the result indices to insert slices at
- `shape`: The shape of the result tensor.
- `batchDimensions`: The number of batch dimensions
- `mode`: The type of update to use on the destination
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object

## Discussion

Discussion Scatters the slices in updatesTensor to the result tensor along the indices in indicesTensor. The scatter is defined as B = batchDims  U = updates.rank - B  P = res.rank - B  Q = inds.rank - B  K = inds.shape[-1]  index_slice = indices[i_{b0},...,i_{bB},i_{0},..,i_{Q-1}]  res[i_{b0},...,i_{bB},index_slice[0],...,index_slice[K-1]] = updates[i_{b0},...,i_{bB},i_{0},...,i_{Q-1}]  Collisions will be summed, and slices not set by indices are set to 0. The tensors have the following shape requirements K <= P  U = (P-K) + Q-1  indices.shape[0:Q-1] = updates.shape[0:Q-1]  updates.shape[Q:U] = res.shape[K:P]
