<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreML",
  "identifier" : "/documentation/CoreML/MLTensor/reversed(alongAxes:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core ML",
      "CoreML"
    ],
    "preciseIdentifier" : "s:6CoreML8MLTensorV8reversed9alongAxesACSid_tF::OverloadGroup"
  },
  "title" : "reversed(alongAxes:)"
}
-->

# reversed(alongAxes:)

Returns a new tensor with the specified dimensions reversed.

```
func reversed(alongAxes axes: Int...) -> MLTensor
```

## Parameters

`axes`

The indices of the dimensions to reverse. Must be in the range `[-rank, rank)`.

## Return Value

A new tensor with the same shape and scalar type with the specified dimensions reversed.

## Discussion

For example:

```swift
let x = MLTensor(shape: [4], scalars: [0,  1,  2,  3], scalarType: Float.self)
let y = x.reversed(alongAxes: 0)
// [3, 2, 1, 0]
```

---

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)