Sum
Function Usage
Image processing algorithm, tensor Sum algorithm to sum up the number of channels, supporting float16, float32, and uint8 data types. Asynchronous calling is supported. The inplace operation is not supported.
Only Atlas inference product support this API.
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.
- The input supports NHWC and HWC, and the number of channels ranges from 1 to 4. The input and output parameters must match the tensor types and the number of channels.
- For the Atlas inference product, when the data type of the input tensor is float32 and the size is greater than 480p (640 x 480), or when the data type of the input tensor is float16 and the size is greater than 540p (960 x 540), the compute performance of Sum is better than that of cv::sum on the CPU.
Prototype
1 | APP_ERROR Sum(const Tensor &src, Tensor &dst, AscendStream& stream = AscendStream::DefaultStream()); |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
src |
Input |
Tensor class, cardinal number, 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. If the shape of the input tensor is NHWC, the output shape is NC. If the shape of the input tensor is HWC, the output shape is C. For example, if the input tensor shape is [2, 16, 16, 3], the output tensor shape is [2,3]. |
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. |