Contents

reversed(alongAxes:)

Returns a new tensor with the specified dimensions reversed.

Declaration

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:

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