Sort
Function Usage
Image processing algorithm, tensor sorting operation (Sort). The float16, float32, and uint8 data types are supported by input and output tensors. Asynchronous calling is supported. Preloading is supported. (The attr attribute needs to be added during preloading. For details, see Example of the Preloading File of the Initialization Operator.) The inplace operation is not supported.
It is supported by the Atlas inference product and
The following conditions must be met:
- The input and output tensors must be on the device or DVPP side, and the parameters (stream and data memory) must be on the same device.
- For synchronization, the device where the data memory is located must be the same as the initialized device.
- The input and output parameters must match the tensor types. The input and output dimensions can only be HW.
- For the Atlas inference product, when the data type of the input tensor is float32 or float16 and the size is greater than 480p (640 x 480), or when the data type of the input tensor is uint8 and the size is greater than 1080p (1920 x 1080), the compute performance of Sort is better than that of cv::sort on the CPU.
- For the
Atlas 200I/500 A2 inference product , when the input size is greater than 720p (1280 x 720), the compute performance is better than that of cv::sort on the CPU.
Prototype
1 | APP_ERROR Sort(const Tensor &src, Tensor &dst, int axis, bool descending, AscendStream& stream = AscendStream::DefaultStream()); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
src |
Input |
Tensor class, input tensor. The float16, float32, or uint8 data types are supported. Only the HW dimension input is supported. |
dst |
Output |
Tensor class, output tensor. The tensor content refers to the result after sorting. Only the float16, float32, and uint8 types of output are supported. Empty tensors can be passed. If dst is not an empty tensor, call Tensor.Malloc() to allocate memory in advance. |
axis |
Input |
Specifies the sorting dimension. The value range is [0, 1]. 0 indicates that data is sorted by height, and 1 indicates that data is sorted by width. |
descending |
Input |
Ascending or descending order. The default value is false, indicating the ascending order. |
stream |
Input |
AscendStream type. The default value is AscendStream::DefaultStream(). When the parameter value is the default value, the API calling is a synchronous operation. In other cases, the API calling is an asynchronous operation. |
Response Parameters
Data Structure |
Description |
|---|---|
APP_ERROR |
For details about the returned error codes, see APP_ERROR Description. |