Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.msort function

PyTorch torch.msort function


PyTorch torch reference manual 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

)

print

(

result

)

The output is:

tensor([1, 2, 3])


PyTorch torch reference manual PyTorch torch reference manual