PyTorch torch.msort function
PyTorch torch reference manual
torch.msort is a function in PyTorch used to return a sorted tensor. It returns a copy of the input tensor sorted in ascending order, similar to flattening the tensor, sorting it, and then reshaping.
Function definition
torch.msort(input)
Usage examples
Example
import
torch
Creating tensors
x
=
torch.
tensor
(
[
3
,
1
,
2
]
)
Returns the sorted tensor
result
=
torch.
msort
(
x
)
(
result
)
The output is:
tensor([1, 2, 3])