<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/reshape(_:shape:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)reshapeTensor:withShape:name:"
  },
  "title" : "reshape(_:shape:name:)"
}
-->

# reshape(_:shape:name:)

Creates a reshape operation and returns the result tensor.

```
func reshape(_ tensor: MPSGraphTensor, shape: [NSNumber], name: String?) -> MPSGraphTensor
```

## Parameters

`tensor`

The tensor to be reshaped.

`shape`

The result tensor shape.

`name`

The name for the operation.

## Return Value

A valid MPSGraphTensor object.

## Discussion

This operation reshapes the input tensor to the target shape.
The shape must be compatible with the input tensor shape, specifically the volume of the input tensor has to match the volume defined by the shape.
The shape is allowed to contain dynamic dimensions (-1) when the result type can be inferred unambiguously.

---

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)