---
title: "transposeTensor(_:dimension:withDimension:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/transposetensor(_:dimension:withdimension:name:)"
---

# transposeTensor(_:dimension:withDimension:name:)

Creates a transpose operation and returns the result tensor.

## Declaration

```swift
func transposeTensor(_ tensor: MPSGraphTensor, dimension dimensionIndex: Int, withDimension dimensionIndex2: Int, name: String?) -> MPSGraphTensor
```

## Parameters

- `tensor`: The tensor to be transposed.
- `dimensionIndex`: The first dimension index to be transposed.
- `dimensionIndex2`: The second dimension index to be transposed.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object.

## Discussion

Discussion Transposes the dimensions dimensionIndex and dimensionIndex2 of the input tensor.
