Function burn::tensor::sort

pub fn sort<B, const D: usize, K>(
    tensor: <K as TensorKind<B>>::Primitive<D>,
    dim: usize,
    descending: bool,
) -> <K as TensorKind<B>>::Primitive<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, where the elements are sorted by value.

§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.