PyTorch torch.msort Function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.msortIt is a function in PyTorch used to return a sorted tensor. It returns a copy of the input tensor arranged in ascending order, similar to sorting the tensor after flattening and then reshaping.

Function Definition

torch.msort(input)

Usage Example

Example

import torch

# Create tensor
x = torch.tensor([3, 1, 2])

# Return sorted tensor
result = torch.msort(x)
print(result)

The output result is:

tensor([1, 2, 3])

Pytorch torch 参考手册PyTorch torch Reference Manual

Other Extensions