Reduce

Function Usage

Image processing algorithm, tensor reduce operation (Reduce). The float16, float32, and uint8 data types are supported. Asynchronous calling and preloading are supported. See Example of the Preloading File of the Initialization Operator.

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 Reduce(const Tensor &src, Tensor &dst, const MxBase::ReduceDim &rDim, const MxBase::ReduceType &rType, AscendStream& stream = AscendStream::DefaultStream());

Parameters

Parameter

Input/Output

Description

src

Input

Tensor of the float16, float32, or uint8 type. The HW, HWC, or NHWC dimension input is supported. The number of supported channels ranges from 1 to 4.

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. The output shape is the result after the input shape eliminates the reduction axis. For example, if the input tensor is [2,32,16,3] and the reduction axis is H, the shape of the output tensor is [2,16,3],

rDim

Input

ReduceDim enumeration type, which specifies the reduction axis. The height and width dimensions can be reduced. For details, see ReduceDim.

rType

Input

ReduceType enumeration, which reduces the operations. Operations to get the sum, average, maximum, and minimum values are supported. For details, see ReduceType.

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.