Multiply

Function Usage

Image processing algorithms, tensor Multiply algorithm, supporting float16, float32, and uint8 data types. 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 of prototype 2. For details, 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.
  • This API is used for saturation calculation. When the dst data type is uint8 and the data value is greater than the maximum uint8 value (or less than the minimum uint8 value), the dst value is 255 (or 0) and no rewind occurs.
  • The input and output parameters cannot exceed four dimensions, and must match the tensor shapes.
  • When prototype 1 is called, the input and output data types must be consistent. When prototype 2 is called, input data types can be different, and the output dst data type is consistent with the input tensor that delivers high precision.
  • Atlas inference product: For prototype 1, when the input size is greater than 720p (1280 x 720), the compute performance is better than that of cv::multiply on the CPU. For prototype 2, when the input size is greater than 480p (640 x 480), the compute performance is better than that of cv::multiply 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::multiply on the CPU.

Prototype

Prototype 1:

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

Prototype 2:

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

Parameters

Parameter

Input/Output

Description

src1

Input

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

src2

Input

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

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.

scale

Input

Double type, input scalar. The result of multiplying src1 and src2 of the input tensor, and then multiplied by the scalar.

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.