Pooling Layer#

The pooling layer API documentation

miopenPoolingMode_t#

enum miopenPoolingMode_t#

Pooling layer mode

Values:

enumerator miopenPoolingMax#

Maximum pooling

enumerator miopenPoolingAverage#

Average pooling

enumerator miopenPoolingAverageInclusive#

Inclusive Average pooling

miopenIndexType_t#

enum miopenIndexType_t#

MIOpen index datatypes.

Values:

enumerator miopenIndexUint8#

8-bit unsigned

enumerator miopenIndexUint16#

16-bit unsigned

enumerator miopenIndexUint32#

32-bit unsigned

enumerator miopenIndexUint64#

64-bit unsigned

miopenCreatePoolingDescriptor#

miopenStatus_t miopenCreatePoolingDescriptor(miopenPoolingDescriptor_t *poolDesc)#

Creates a pooling layer descriptor.

Parameters:

poolDesc – Pointer to a pooling layer descriptor (output)

Returns:

miopenStatus_t

miopenSet2dPoolingDescriptor#

miopenStatus_t miopenSet2dPoolingDescriptor(miopenPoolingDescriptor_t poolDesc, miopenPoolingMode_t mode, int windowHeight, int windowWidth, int pad_h, int pad_w, int stride_h, int stride_w)#

Sets a 2-D pooling layer descriptor details.

Sets the window shape, padding, and stride for a previously created 2-D pooling descriptor.

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (output)

  • mode – Pooling mode enum (input)

  • windowHeight – Input window height dimension (input)

  • windowWidth – Input window width dimension (input)

  • pad_h – Number of elements to pad height (input)

  • pad_w – Number of elements to pad width (input)

  • stride_h – Vertical stride (input)

  • stride_w – Horizontal stride (input)

Returns:

miopenStatus_t

miopenSetNdPoolingDescriptor#

miopenStatus_t miopenSetNdPoolingDescriptor(miopenPoolingDescriptor_t poolDesc, const miopenPoolingMode_t mode, int nbDims, const int *windowDimA, const int *padA, const int *stridesA)#

Set details of a N-D pooling layer descriptor.

Set the window shape, padding, and stride for a previously created N-D pooling descriptor.

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (input/output)

  • mode – Pooling mode enum (input)

  • nbDims – Dimension of the pooling (input)

  • windowDimA – Array of input window dimensions with length equal to or larger than dimsRequested (input)

  • padA – Array of number of elements to padding with length equal to or larger than dimsRequested (input)

  • stridesA – Array of stride parameter with length equal to or larger than dimsRequested (input)

Returns:

miopenStatus_t

miopenSetPoolingIndexType#

miopenStatus_t miopenSetPoolingIndexType(miopenPoolingDescriptor_t poolDesc, miopenIndexType_t index_type)#

Set index data type for pooling layer. The default indexing type is uint8_t. Users can set the index type to any of the miopenIndexType_t sizes; 8, 16, 32, or 64 bit unsigned integers.

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (input)

  • index_type – Index type (input)

Returns:

miopenStatus_t

miopenGetPoolingIndexType#

miopenStatus_t miopenGetPoolingIndexType(miopenPoolingDescriptor_t poolDesc, miopenIndexType_t *index_type)#

Get the index data type for pooling layer. The index type to any of the miopenIndexType_t sizes; 8, 16, 32, or 64 bit unsigned integers.

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (input)

  • index_type – Index type (output)

Returns:

miopenStatus_t

miopenGet2dPoolingDescriptor#

miopenStatus_t miopenGet2dPoolingDescriptor(const miopenPoolingDescriptor_t poolDesc, miopenPoolingMode_t *mode, int *windowHeight, int *windowWidth, int *pad_h, int *pad_w, int *stride_h, int *stride_w)#

Gets a 2-D pooling layer descriptor details.

Gets the window shape, padding, and stride for a previously created 2-D pooling descriptor.

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (input)

  • mode – Pooling mode enum (output)

  • windowHeight – Input window height dimension (output)

  • windowWidth – Input window width dimension (output)

  • pad_h – Number of elements to pad height (output)

  • pad_w – Number of elements to pad width (output)

  • stride_h – Vertical stride (output)

  • stride_w – Horizontal stride (output)

Returns:

miopenStatus_t

miopenGetNdPoolingDescriptor#

miopenStatus_t miopenGetNdPoolingDescriptor(const miopenPoolingDescriptor_t poolDesc, int nbDimsRequested, miopenPoolingMode_t *mode, int *nbDims, int *windowDimA, int *padA, int *stridesA)#

Get details of a N-D pooling layer descriptor.

Get the window shape, padding, and stride for a previously created N-D pooling descriptor.

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (input)

  • nbDimsRequested – Dimension of the expected pooling descriptor (input)

  • mode – Pooling mode enum (output)

  • nbDims – Actual dimension of the pooling descriptor (output)

  • windowDimA – Array of input window dimensions with length equal to or larger than dimsRequested (output)

  • padA – Array of number of elements to padding with length equal to or larger than dimsRequested (output)

  • stridesA – Array of stride parameter with length equal to or larger than dimsRequested (output)

Returns:

miopenStatus_t

miopenGetPoolingForwardOutputDim#

miopenStatus_t miopenGetPoolingForwardOutputDim(const miopenPoolingDescriptor_t poolDesc, const miopenTensorDescriptor_t tensorDesc, int *n, int *c, int *h, int *w)#

Gets the shape of the output tensor for 2-D pooling.

Retrieve the tensor dimensions for the forward 2-D pooling. This call is required for the forward if the output dimensions are different than the input tensor dimensions.

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (input)

  • tensorDesc – Input tensor descriptor (input)

  • n – Mini-batch dim (output)

  • c – Number of channels (output)

  • h – Heights of input map (output)

  • w – Width of input map (output)

Returns:

miopenStatus_t

miopenGetPoolingNdForwardOutputDim#

miopenStatus_t miopenGetPoolingNdForwardOutputDim(const miopenPoolingDescriptor_t poolDesc, const miopenTensorDescriptor_t tensorDesc, int dims, int *tensorDimArr)#

Gets the shape of the output tensor for N-D pooling.

Retrieve the tensor dimensions for the forward N-D pooling. This call is required for the forward if the output dimensions are different than the input tensor dimensions.

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (input)

  • tensorDesc – Input tensor descriptor (input)

  • dims – Dimension of the pooling (input)

  • tensorDimArr – Array of tensor dimension (output)

Returns:

miopenStatus_t

miopenPoolingGetWorkSpaceSize#

miopenStatus_t miopenPoolingGetWorkSpaceSize(const miopenTensorDescriptor_t yDesc, size_t *workSpaceSize)#

Get the amount of GPU memory required for pooling.

Retrieves the amount of workspace in bytes require for pooling. This call is required to determine the amount of GPU memory needed for the backwards pooling algorithms. For max- pooling, an assumption is that index data type is uint8_t, therefore the returned workspace size will be based on this assumption even if the user sets the index type with miopenSetPoolingIndexType().

Parameters:
  • yDesc – Descriptor for pooling layer (input)

  • workSpaceSize – Pointer to workSpaceSize (output)

Returns:

miopenStatus_t

miopenPoolingGetWorkSpaceSizeV2#

miopenStatus_t miopenPoolingGetWorkSpaceSizeV2(const miopenPoolingDescriptor_t poolDesc, const miopenTensorDescriptor_t yDesc, size_t *workSpaceSize)#

Get the amount of GPU memory required for pooling.

Retrieves the amount of workspace in bytes require for pooling. This call is required to determine the amount of GPU memory needed for the backwards pooling algorithms. For max- pooling, there is no assumption on index data type. As the user can set the index datatype size using miopenSetPoolingIndexType().

Parameters:
  • poolDesc – Pointer to a pooling layer descriptor (input)

  • yDesc – Descriptor for pooling layer (input)

  • workSpaceSize – Pointer to workSpaceSize (output)

Returns:

miopenStatus_t

miopenPoolingForward#

miopenStatus_t miopenPoolingForward(miopenHandle_t handle, const miopenPoolingDescriptor_t poolDesc, const void *alpha, const miopenTensorDescriptor_t xDesc, const void *x, const void *beta, const miopenTensorDescriptor_t yDesc, void *y, bool do_backward, void *workSpace, size_t workSpaceSize)#

Execute a forward pooling layer.

Runs forward pooling. miopenGetPoolingForwardOutputDim() should be called before miopenPoolingForward(). If the parameter do_backward == 0, then set workSpace = nullptr and workSpaceSize = 0. However, for back-propagation do_backwards must be set to 1 in miopenPoolingForward().

Parameters:
  • handle – MIOpen handle (input)

  • poolDesc – Descriptor for pooling layer (input)

  • alpha – Floating point scaling factor, allocated on the host (input)

  • xDesc – Tensor descriptor for data input tensor x (input)

  • x – Data tensor x (input)

  • beta – Floating point shift factor, allocated on the host (input)

  • yDesc – Tensor descriptor for output data tensor y (input)

  • y – Data tensor y (output)

  • do_backward – Boolean to toggle save data in workspace for backwards pass (input)

  • workSpace – Pointer user allocated memory (input)

  • workSpaceSize – Size in bytes of the memory needed (input)

Returns:

miopenStatus_t

miopenPoolingBackward#

miopenStatus_t miopenPoolingBackward(miopenHandle_t handle, const miopenPoolingDescriptor_t poolDesc, const void *alpha, const miopenTensorDescriptor_t yDesc, const void *y, const miopenTensorDescriptor_t dyDesc, const void *dy, const miopenTensorDescriptor_t xDesc, const void *x, const void *beta, const miopenTensorDescriptor_t dxDesc, void *dx, void *workSpace)#

Execute a backward pooling layer.

Runs backward pooling. miopenPoolingGetWorkSpaceSize() must be called before miopenPoolingBackward() to determine the amount of workSpace to be allocated.

Parameters:
  • handle – MIOpen handle (input)

  • poolDesc – Descriptor for pooling layer (input)

  • alpha – Floating point scaling factor, allocated on the host (input)

  • yDesc – Tensor descriptor for output data tensor y (input)

  • y – Data tensor y (input)

  • dyDesc – Tensor descriptor for data input tensor dy (input)

  • dy – Data delta tensor dy (input)

  • xDesc – Tensor descriptor for output data tensor x (input)

  • x – Data tensor x (output)

  • beta – Floating point shift factor, allocated on the host (input)

  • dxDesc – Tensor descriptor for tensor dx (input)

  • dx – Weights delta tensor dx (output)

  • workSpace – Pointer to user allocated workspace (input)

Returns:

miopenStatus_t

miopenDestroyPoolingDescriptor#

miopenStatus_t miopenDestroyPoolingDescriptor(miopenPoolingDescriptor_t poolDesc)#

Destroys the pooling descriptor object.

Parameters:

poolDesc – Pooling tensor descriptor type (input)

Returns:

miopenStatus_t