<!--
{
  "availability" : [
    "iOS: 14.0.0 - 17.0.0",
    "iPadOS: 14.0.0 - 17.0.0",
    "macCatalyst: 14.0.0 - 17.0.0",
    "macOS: 11.0.0 - 14.0.0",
    "tvOS: 14.0.0 - 17.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MLCompute",
  "identifier" : "/documentation/MLCompute/MLCGraph/transpose(dimensions:source:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "ML Compute",
      "MLCompute"
    ],
    "preciseIdentifier" : "s:So8MLCGraphC9MLComputeE9transpose10dimensions6sourceSo9MLCTensorCSgSaySiG_AHtF"
  },
  "title" : "transpose(dimensions:source:)"
}
-->

# transpose(dimensions:source:)

Adds a new transpose layer to the graph using the dimensions and source tensor you specify.

```
func transpose(dimensions: [Int], source: MLCTensor) -> MLCTensor?
```

## Parameters

`dimensions`

An array that contains the desired ordering of dimensions.

`source`

The source tensor.

## Return Value

A result tensor.

## Discussion

The dimensions array specifies the input axis source for each output axis. In other words, the `n`th element in the dimensions array specifies the input axis source for the `n`th axis in the output.

> Note:
> The batch dimension is typically axis 0, which you can’t transpose.

---

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)