mlx_rs::ops

Function transpose

Source
pub fn transpose(a: impl AsRef<Array>, axes: &[i32]) -> Result<Array>
Expand description

Transpose the dimensions of the array. Returns an error if the axes are invalid.

§Params

  • a: The input array.
  • axes: Specifies the source axis for each axis in the new array. The default is to reverse the axes.

§Example

use mlx_rs::{Array, ops::*};

let x = Array::from_slice(&[1, 2, 3, 4, 5, 6], &[2, 3]);
let y1 = transpose(&x, &[0, 1]).unwrap();
let y2 = transpose_all(&x).unwrap();

§See also