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 Atlas 200I/500 A2 inference product.

The following conditions must be met:

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 Atlas 200I/500 A2 inference product is opposite to that on the Atlas inference product.

  • Atlas 200I/500 A2 inference product: large to small values for ascending order; small to large values for descending order.
  • Atlas inference product: small to large values for ascending order; large to small values for descending order.

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.