SortOperation
Description
Implements postprocessing computation by sorting input tensors in descending order in the last dimension, retaining the maximum num elements, and outputting the sorted tensor and the index corresponding to each element.
Operator Context

Definition
struct SortParam {
SVector<int32_t> num;
uint8_t rsv[8] = {0};
};
Parameters
Member |
Type |
Default Value |
Description |
|---|---|---|---|
num |
SVector<int32_t> |
- |
Maximum number of elements that is retained after sorting. num is an SVector containing only one value. The value must be greater than 0 and less than or equal to the size of the last dimension of input x. |
rsv[8] |
uint8_t |
{0} |
Reserved |
Input
Parameter |
Dimension |
Data Type |
Format |
Description |
|---|---|---|---|---|
x |
[-1,…,-1] The value -1 indicates that the size of the current dimension is not restricted. |
float16/bf16/float |
ND |
The last dimension must contain at least num elements. |
Output
Parameter |
Dimension |
Data Type |
Format |
Description |
|---|---|---|---|---|
output |
[-1,…,num] The value -1 indicates that the size of the current dimension is not restricted. |
float16/bf16/float |
ND |
Maximum num elements after sorting in the last dimension. |
indices |
[-1,…,num] The value -1 indicates that the size of the current dimension is not restricted. |
int32 |
ND |
Original indexes corresponding to the maximum num elements. |
Restrictions
- num is an SVector containing only one value. The value must be greater than 0 and less than or equal to the size of the last dimension of input x.
Atlas inference products : Not support the float data type.
API Calling Example
Input:
num = [1]
x = [[3.0, 4.0],
[5.0, 6.0]]
Output:
output = [[4.0],
[6.0]]
indices = [[1.0],
[1.0]]