---
title: "reshape(_:shapeTensor:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/reshape(_:shapetensor:name:)"
---

# reshape(_:shapeTensor:name:)

Creates a reshape operation and returns the result tensor.

## Declaration

```swift
func reshape(_ tensor: MPSGraphTensor, shapeTensor: MPSGraphTensor, name: String?) -> MPSGraphTensor
```

## Parameters

- `tensor`: The tensor to be reshaped.
- `shapeTensor`: A 1D tensor of type MPSDataTypeInt32 or MPSDataTypeInt64, that contains the target shape values.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object.

## Discussion

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