Compare

Function Usage

Image processing algorithm, tensor comparison operation (Compare). The float16, float32, and uint8 data types are supported by input and output tensors. Asynchronous calling is supported. The inplace operation is not supported.

It is supported by the Atlas inference product and Atlas 200I/500 A2 inference product.

For the Atlas 200I/500 A2 inference product, 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 following conditions must be met:

Prototype

1
APP_ERROR Compare(const Tensor &src1, const Tensor &src2, Tensor &dst, const CmpOp cmpOp = CmpOp::CMP_EQ, AscendStream& stream = AscendStream::DefaultStream());

Parameters

Parameters

Parameter

Input/Output

Description

src1

Input

Tensor class, input tensor, supporting the float16, float32, and uint8 data types. The data memory must be on the device or DVPP side.

src2

Input

Tensor class, input tensor, supporting the float16, float32, and uint8 data types. The data memory must be on the device or DVPP side.

dst

Output

Tensor class, output tensor. When the comparison result is as expected, the tensor result is 255. Otherwise, the tensor result is 0. The float16, float32, and uint8 data types are supported. Empty tensors can be passed. If dst is not an empty tensor, call Tensor.Malloc() to allocate memory in advance.

cmpOp

Input

Enumeration value, corresponding to the tensor comparison type. Only equal to, not equal to, less than, greater than, less than or equal to, and greater than or equal to are supported. For details, see CmpOp.

1
2
3
4
5
6
7
8
enum class CmpOp { 
     CMP_EQ = 0, 
     CMP_NE, 
     CMP_LT, 
     CMP_GT, 
     CMP_LE, 
     CMP_GE
 };

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.