TensorReduce

TensorReduce#

MIOpen: TensorReduce
TensorReduce

Macros

#define MIOPEN_API_VERSION_REDUCE_TENSOR   1
 Version of TensorReduce API. Applications may use it to ensure backward compatibility with older library versions. More...
 

Enumerations

enum  miopenReduceTensorOp_t {
  MIOPEN_REDUCE_TENSOR_ADD = 0 ,
  MIOPEN_REDUCE_TENSOR_MUL ,
  MIOPEN_REDUCE_TENSOR_MIN ,
  MIOPEN_REDUCE_TENSOR_MAX ,
  MIOPEN_REDUCE_TENSOR_AMAX ,
  MIOPEN_REDUCE_TENSOR_AVG ,
  MIOPEN_REDUCE_TENSOR_NORM1 ,
  MIOPEN_REDUCE_TENSOR_NORM2 = 7
}
 
enum  miopenReduceTensorIndices_t {
  MIOPEN_REDUCE_TENSOR_NO_INDICES = 0 ,
  MIOPEN_REDUCE_TENSOR_FLATTENED_INDICES = 1
}
 
enum  miopenIndicesType_t {
  MIOPEN_32BIT_INDICES = 0 ,
  MIOPEN_64BIT_INDICES = 1 ,
  MIOPEN_16BIT_INDICES = 2 ,
  MIOPEN_8BIT_INDICES = 3
}
 

Functions

 MIOPEN_DECLARE_OBJECT (miopenReduceTensorDescriptor)
 Creates the miopenReduceTensorDescriptor_t type. More...
 
miopenStatus_t miopenCreateReduceTensorDescriptor (miopenReduceTensorDescriptor_t *reduceTensorDesc)
 Creates the ReduceTensor descriptor object. More...
 
miopenStatus_t miopenDestroyReduceTensorDescriptor (miopenReduceTensorDescriptor_t reduceTensorDesc)
 Destroy the ReduceTensor descriptor object. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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) More...
 

Detailed Description

Macro Definition Documentation

◆ MIOPEN_API_VERSION_REDUCE_TENSOR

#define MIOPEN_API_VERSION_REDUCE_TENSOR   1

Version of TensorReduce API. Applications may use it to ensure backward compatibility with older library versions.

  • 0 or undefined - Initial API. Supported operations: ADD, MIN, MIN, MAX.
  • 1 - Added AMAX, AVG, NORM1, NORM2 ops.

Enumeration Type Documentation

◆ miopenIndicesType_t

Reduction Indices types

Enumerator
MIOPEN_32BIT_INDICES 

32-bit unsigned integer indices

MIOPEN_64BIT_INDICES 

64-bit unsigned integer indices

MIOPEN_16BIT_INDICES 

16-bit unsigned integer indices

MIOPEN_8BIT_INDICES 

8-bit unsigned integer indices

Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenReduceTensorIndices_t

Reduction Indices computation modes

Enumerator
MIOPEN_REDUCE_TENSOR_NO_INDICES 

Does not compuate indices

MIOPEN_REDUCE_TENSOR_FLATTENED_INDICES 

Compute the relative, flatted indices

Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenReduceTensorOp_t

Tensor Reduction operation types

Nan numbers propagation modes

Enumerator
MIOPEN_REDUCE_TENSOR_ADD 

the operation is adding the values of the reduced elements

MIOPEN_REDUCE_TENSOR_MUL 

the operation is multiplying the values of the reduced elements

MIOPEN_REDUCE_TENSOR_MIN 

the operation is getting the minimum value of the reduced elements

MIOPEN_REDUCE_TENSOR_MAX 

the operation is getting the maximum value of the reduced elements

MIOPEN_REDUCE_TENSOR_AMAX 

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

MIOPEN_REDUCE_TENSOR_AVG 

the operation is getting the averaged value of the reduced elements

MIOPEN_REDUCE_TENSOR_NORM1 

the operation is adding the absolute values of the reduced elements

MIOPEN_REDUCE_TENSOR_NORM2 

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

Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

Function Documentation

◆ MIOPEN_DECLARE_OBJECT()

MIOPEN_DECLARE_OBJECT ( miopenReduceTensorDescriptor  )

Creates the miopenReduceTensorDescriptor_t type.

◆ miopenCreateReduceTensorDescriptor()

miopenStatus_t miopenCreateReduceTensorDescriptor ( miopenReduceTensorDescriptor_t *  reduceTensorDesc)

Creates the ReduceTensor descriptor object.

Parameters
reduceTensorDescPointer to a ReduceTensor descriptor type
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ miopenDestroyReduceTensorDescriptor()

miopenStatus_t miopenDestroyReduceTensorDescriptor ( miopenReduceTensorDescriptor_t  reduceTensorDesc)

Destroy the ReduceTensor descriptor object.

Parameters
reduceTensorDescReduceTensor descriptor type (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ 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
reduceTensorDescPointer to the ReduceTensor descriptor object (input)
reduceTensorOpPointer to enumerant specifying the operation used by ReduceTensor (output)
reduceTensorCompTypePointer to enumerant specifying the data type used with ReduceTensor operation (output)
reduceTensorNanOptPointer to enumerant specifying the Nan number propagation mode (output)
reduceTensorIndicesPointer to enumerant specifying the indices modes used by ReduceTensor (output)
reduceTensorIndicesTypePointer to enumerant specifying the data type of the indices (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ 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
handleMIOpen Handle (input)
reduceTensorDescPointer to the ReduceTensor descriptor object (input)
aDescPointer to the input tensor descriptor (input)
cDescPointer to the output tensor descriptor (input)
sizeInBytesPointer to data to return the minimum index space size
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ 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
handleMIOpen Handle (input)
reduceTensorDescPointer to the ReduceTensor descriptor object (input)
aDescPointer to the input tensor descriptor (input)
cDescPointer to the output tensor descriptor (input)
sizeInBytesPointer to data to return the minimum workspace size
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ 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
handleMIOpen Handle (input)
reduceTensorDescPointer to the ReduceTensor descriptor object (input)
indicesAddress of the allocated indices data space (output)
indicesSizeInBytesSize in bytes of the allocated indices data space (input)
workspaceAddress of the allocated workspace data (input)
workspaceSizeInBytesSize in bytes of the allocated workspace data (input)
alphaPointer to scale factor for data in input tensor A (input)
aDescPointer to the tensor descriptor for input tensor A (input)
APointer to the data of input tensor A (input)
betaPointer to scale factor for data in output tensor C (input)
cDescPointer to the tensor descriptor for output tensor C (input)
CPointer to the data of output tensor C (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.

◆ 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
reduceTensorDescPointer to the ReduceTensor descriptor object (output)
reduceTensorOpEnumerant specifying the operation used by ReduceTensor (input)
reduceTensorCompTypeEnumerant specifying the data type used with ReduceTensor operation (input)
reduceTensorNanOptEnumerant specifying the Nan number propagation mode (input)
reduceTensorIndicesEnumerant specifying the indices modes used by ReduceTensor (input)
reduceTensorIndicesTypeEnumerant specifying the data type of the indices (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/latest/include/miopen/miopen.h.