Function burn::tensor::sort_with_indices

source ·
pub fn sort_with_indices<B, const D: usize, K>(
    tensor: <K as TensorKind<B>>::Primitive<D>,
    dim: usize,
    descending: bool
) -> (<K as TensorKind<B>>::Primitive<D>, <B as Backend>::IntTensorPrimitive<D>)
where B: Backend, K: TensorKind<B> + BasicOps<B>, <K as BasicOps<B>>::Elem: Element,
Expand description

Sort the elements of the input tensor by value along a given dimension.

This sort is unstable (i.e., may reorder equal elements).

§Arguments

  • tensor - The input tensor.
  • dim - The axis along which to sort.
  • descending - The sorting order.

§Returns

A tensor with the same shape as the input tensor and corresponding indices, where the elements are sorted by value and the indices map back to the original input tensor.

§Remarks

This is a fallback solution that used only when the backend doesn’t have the corresponding implementation. Ideally, it is supposed to be implemented by the backend and the backend implementation will be resolved by static dispatch. It is not designed for direct usage by users, and not recommended to import or use this function directly.