mlx_rs::ops::indexing

Function topk

Source
pub fn topk(
    a: impl AsRef<Array>,
    k: i32,
    axis: impl Into<Option<i32>>,
) -> Result<Array>
Expand description

Returns the k largest elements from the input along a given axis.

The elements will not necessarily be in sorted order.

See topk_all for the flattened array.

ยงParams

  • a: The input array.
  • k: The number of elements to return.
  • axis: Axis to sort over. Default to -1 if not specified.