Reduction Layer#

The reduction layer API documentation

miopenReduceTensorOp_t#

enum miopenReduceTensorOp_t#

Tensor Reduction operation types

Nan numbers propagation modes

Values:

enumerator MIOPEN_REDUCE_TENSOR_ADD#

the operation is adding the values of the reduced elements

enumerator MIOPEN_REDUCE_TENSOR_MUL#

the operation is multiplying the values of the reduced elements

enumerator MIOPEN_REDUCE_TENSOR_MIN#

the operation is getting the minimum value of the reduced elements

enumerator MIOPEN_REDUCE_TENSOR_MAX#

the operation is getting the maximum value of the reduced elements

enumerator MIOPEN_REDUCE_TENSOR_AMAX#

the operation is getting the maximum absolute value of the reduced elements

enumerator MIOPEN_REDUCE_TENSOR_AVG#

the operation is getting the averaged value of the reduced elements

enumerator MIOPEN_REDUCE_TENSOR_NORM1#

the operation is adding the absolute values of the reduced elements

enumerator MIOPEN_REDUCE_TENSOR_NORM2#

the operation is getting the square root of the sum of squares of the reduced elements

miopenNanPropagation_t#

enum miopenNanPropagation_t#

Values:

enumerator MIOPEN_NOT_PROPAGATE_NAN#

does not propagate Nan number

enumerator MIOPEN_PROPAGATE_NAN#

propagate the Nan number by the Reduction operation

miopenReduceTensorIndices_t#

enum miopenReduceTensorIndices_t#

Reduction Indices computation modes

Values:

enumerator MIOPEN_REDUCE_TENSOR_NO_INDICES#

Does not compuate indices

enumerator MIOPEN_REDUCE_TENSOR_FLATTENED_INDICES#

Compute the relative, flatted indices

miopenIndicesType_t#

enum miopenIndicesType_t#

Reduction Indices types

Values:

enumerator MIOPEN_32BIT_INDICES#

32-bit unsigned integer indices

enumerator MIOPEN_64BIT_INDICES#

64-bit unsigned integer indices

enumerator MIOPEN_16BIT_INDICES#

16-bit unsigned integer indices

enumerator MIOPEN_8BIT_INDICES#

8-bit unsigned integer indices

miopenCreateReduceTensorDescriptor#

miopenStatus_t miopenCreateReduceTensorDescriptor(miopenReduceTensorDescriptor_t *reduceTensorDesc)#

Creates the ReduceTensor descriptor object.

Parameters:

reduceTensorDesc – Pointer to a ReduceTensor descriptor type

Returns:

miopenStatus_t

miopenDestroyReduceTensorDescriptor#

miopenStatus_t miopenDestroyReduceTensorDescriptor(miopenReduceTensorDescriptor_t reduceTensorDesc)#

Destroy the ReduceTensor descriptor object.

Parameters:

reduceTensorDesc – ReduceTensor descriptor type (input)

Returns:

miopenStatus_t

miopenSetReduceTensorDescriptor#

miopenStatus_t miopenSetReduceTensorDescriptor(miopenReduceTensorDescriptor_t reduceTensorDesc, miopenReduceTensorOp_t reduceTensorOp, miopenDataType_t reduceTensorCompType, miopenNanPropagation_t reduceTensorNanOpt, miopenReduceTensorIndices_t reduceTensorIndices, miopenIndicesType_t reduceTensorIndicesType)#

Initialize a ReduceTensor descriptor object.

Parameters:
  • reduceTensorDesc – Pointer to the ReduceTensor descriptor object (output)

  • reduceTensorOp – Enumerant specifying the operation used by ReduceTensor (input)

  • reduceTensorCompType – Enumerant specifying the data type used with ReduceTensor operation (input)

  • reduceTensorNanOpt – Enumerant specifying the Nan number propagation mode (input)

  • reduceTensorIndices – Enumerant specifying the indices modes used by ReduceTensor (input)

  • reduceTensorIndicesType – Enumerant specifying the data type of the indices (input)

Returns:

miopenStatus_t

miopenGetReduceTensorDescriptor#

miopenStatus_t miopenGetReduceTensorDescriptor(const miopenReduceTensorDescriptor_t reduceTensorDesc, miopenReduceTensorOp_t *reduceTensorOp, miopenDataType_t *reduceTensorCompType, miopenNanPropagation_t *reduceTensorNanOpt, miopenReduceTensorIndices_t *reduceTensorIndices, miopenIndicesType_t *reduceTensorIndicesType)#

Query a ReduceTensor descriptor object.

Parameters:
  • reduceTensorDesc – Pointer to the ReduceTensor descriptor object (input)

  • reduceTensorOp – Pointer to enumerant specifying the operation used by ReduceTensor (output)

  • reduceTensorCompType – Pointer to enumerant specifying the data type used with ReduceTensor operation (output)

  • reduceTensorNanOpt – Pointer to enumerant specifying the Nan number propagation mode (output)

  • reduceTensorIndices – Pointer to enumerant specifying the indices modes used by ReduceTensor (output)

  • reduceTensorIndicesType – Pointer to enumerant specifying the data type of the indices (output)

Returns:

miopenStatus_t

miopenGetReductionIndicesSize#

miopenStatus_t miopenGetReductionIndicesSize(miopenHandle_t handle, const miopenReduceTensorDescriptor_t reduceTensorDesc, const miopenTensorDescriptor_t aDesc, const miopenTensorDescriptor_t cDesc, size_t *sizeInBytes)#

Helper function to query the minimum index space size required by the ReduceTensor call.

Parameters:
  • handle – MIOpen Handle (input)

  • reduceTensorDesc – Pointer to the ReduceTensor descriptor object (input)

  • aDesc – Pointer to the input tensor descriptor (input)

  • cDesc – Pointer to the output tensor descriptor (input)

  • sizeInBytes – Pointer to data to return the minimum index space size

Returns:

miopenStatus_t

miopenGetReductionWorkspaceSize#

miopenStatus_t miopenGetReductionWorkspaceSize(miopenHandle_t handle, const miopenReduceTensorDescriptor_t reduceTensorDesc, const miopenTensorDescriptor_t aDesc, const miopenTensorDescriptor_t cDesc, size_t *sizeInBytes)#

Helper function to query the minimum workspace size required by the ReduceTensor call.

Parameters:
  • handle – MIOpen Handle (input)

  • reduceTensorDesc – Pointer to the ReduceTensor descriptor object (input)

  • aDesc – Pointer to the input tensor descriptor (input)

  • cDesc – Pointer to the output tensor descriptor (input)

  • sizeInBytes – Pointer to data to return the minimum workspace size

Returns:

miopenStatus_t

miopenReduceTensor#

miopenStatus_t miopenReduceTensor(miopenHandle_t handle, const miopenReduceTensorDescriptor_t reduceTensorDesc, void *indices, size_t indicesSizeInBytes, void *workspace, size_t workspaceSizeInBytes, const void *alpha, const miopenTensorDescriptor_t aDesc, const void *A, const void *beta, const miopenTensorDescriptor_t cDesc, void *C)#

TensorReduce function doing reduction on tensor A by implementing C = alpha * reduceOp(A)

  • beta * C

The length of each dimension of output tensor C must match the length of the corresponding dimension of input tensor A or must be equal to 1. The dimensions with length equal to 1 indicate the dimensions of A to be reduced.

Parameters:
  • handle – MIOpen Handle (input)

  • reduceTensorDesc – Pointer to the ReduceTensor descriptor object (input)

  • indices – Address of the allocated indices data space (output)

  • indicesSizeInBytes – Size in bytes of the allocated indices data space (input)

  • workspace – Address of the allocated workspace data (input)

  • workspaceSizeInBytes – Size in bytes of the allocated workspace data (input)

  • alpha – Pointer to scale factor for data in input tensor A (input)

  • aDesc – Pointer to the tensor descriptor for input tensor A (input)

  • A – Pointer to the data of input tensor A (input)

  • beta – Pointer to scale factor for data in output tensor C (input)

  • cDesc – Pointer to the tensor descriptor for output tensor C (input)

  • C – Pointer to the data of output tensor C (output)

Returns:

miopenStatus_t