---
title: "reshape(withMTL4CommandEncoder:sourceArray:dimensionCount:dimensionSizes:destinationArray:)"
framework: metalperformanceshaders
role: symbol
role_heading: Instance Method
path: "metalperformanceshaders/mpsndarrayidentity/reshape(withmtl4commandencoder:sourcearray:dimensioncount:dimensionsizes:destinationarray:)"
---

# reshape(withMTL4CommandEncoder:sourceArray:dimensionCount:dimensionSizes:destinationArray:)

## Declaration

```swift
func reshape(withMTL4CommandEncoder encoder: any MTL4ComputeCommandEncoder, sourceArray: MPSNDArray, dimensionCount numberOfDimensions: Int, dimensionSizes: UnsafeMutablePointer<Int>, destinationArray: MPSNDArray)
```

## Parameters

- `encoder`: The MTL4ComputeCommandEncoder to encode the kernel with.
- `sourceArray`: The source NDArray.
- `numberOfDimensions`: The NDArray’s dimension count.
- `dimensionSizes`: The extents of each dimension of the NDArray.
- `destinationArray`: The destination NDArray. The shape of destinationArray must match numberOfDimensions and dimensionSizes.

## Discussion

Discussion Encode a reshape operation. The encoder associates the commands with MTLStageDispatch. Synchronize your workloads against this stage when using this function to prevent race conditions.
