SortIdx
Function Usage
Image processing algorithm, tensor sorting index operation (SortIdx). The input tensor supports float16, float32, or uint8 data types, but the output tensor supports only the int32 data type. 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 sizes. 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 SortIdx is better than that of cv::sortIdx 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::sortIdx on the CPU.
Prototype
1 | APP_ERROR SortIdx(const Tensor &src, Tensor &dstIdx, 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. |
dstIdx |
Output |
Tensor class, output tensor. The tensor content refers to the index sequence result after sorting. Only the int32 type output is supported. Empty tensors can be passed. If dst is not an empty tensor, call Tensor.Malloc() to allocate memory in advance. If src has the same values, the sorting result of dstIdx (sorting result index) on the
|
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. |