Divide

Function Usage

Image processing algorithms, tensor Divide algorithm, supporting float16, float32, and uint8 data types. Asynchronous calling is supported, and preloading of some function prototypes 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 (see Example of the Preloading File of the Initialization Operator).

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.
  • Handle the issue of out-of-range data type if any.
  • On the Atlas inference product, this API is used for saturation computation. When the data value is out of the range of the data type, data wrapping does not occur. On the Atlas 200I/500 A2 inference product, this API is used for non-saturation computation.
  • The input and output parameters cannot exceed four dimensions, and must match the tensor shapes. src1 and src2 can be of different data types. The dst data type is subject to the one with higher precision, either src1 or src2.
  • For the Atlas inference product, when the input size is greater than 240p (320 x 240), the compute performance is better than that of cv::divide 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::divide on the CPU.

Prototype

Prototype 1:

1
APP_ERROR Divide(const Tensor &src1, const Tensor &src2, Tensor &dst, AscendStream &stream = AscendStream::DefaultStream());

Prototype 2 (not supported by the Atlas 200I/500 A2 inference product):

1
APP_ERROR Divide(const Tensor &src1, const Tensor &src2, Tensor &dst, float scale, AscendStream& stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

src1

Input

Tensor class, dividend, input tensor, supporting float16, float32, and uint8 data types.

src2

Input

Tensor class, divisor, input tensor, supporting float16, float32, and uint8 data types. Elements in src2 cannot be 0.

dst

Output

Tensor class, output tensor, supporting float16, float32, and uint8 data types. An empty tensor can be passed. If dst is not an empty tensor, call Tensor.Malloc() to allocate memory in advance.

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.

scale

Input

Input scalar, float type. The value is the result of multiplying src1 and scalar, and then divided by src2.

Response Parameters

Data Structure

Description

APP_ERROR

For details about the returned error codes, see APP_ERROR Description.