Pooling Layer

The pooling layer API documentation

miopenPoolingMode_t

enum miopenPoolingMode_t

Pooling layer mode

Values:

miopenPoolingMax = 0

Maximum pooling

miopenPoolingAverage = 1

Average pooling

miopenPoolingAverageInclusive = 2

Inclusive Average pooling

miopenIndexType_t

enum miopenIndexType_t

MIOpen index datatypes.

Values:

miopenIndexUint8 = 0

8-bit unsigned

miopenIndexUint16 = 1

16-bit unsigned

miopenIndexUint32 = 2

32-bit unsigned

miopenIndexUint64 = 3

64-bit unsigned

miopenCreatePoolingDescriptor

miopenStatus_t miopenCreatePoolingDescriptor(miopenPoolingDescriptor_t *poolDesc)

Creates a pooling layer descriptor.

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

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.

Return
miopenStatus_t
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)

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.

Return
miopenStatus_t
Parameters
  • poolDesc: Pointer to a pooling layer descriptor (input)
  • index_type: Index type (input)

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.

Return
miopenStatus_t
Parameters
  • poolDesc: Pointer to a pooling layer descriptor (input)
  • index_type: Index type (output)

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.

Return
miopenStatus_t
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)

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.

Return
miopenStatus_t
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)

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().

Return
miopenStatus_t
Parameters
  • yDesc: Descriptor for pooling layer (input)
  • workSpaceSize: Pointer to workSpaceSize (output)

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().

Return
miopenStatus_t
Parameters
  • poolDesc: Pointer to a pooling layer descriptor (input)
  • yDesc: Descriptor for pooling layer (input)
  • workSpaceSize: Pointer to workSpaceSize (output)

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().

Return
miopenStatus_t
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)

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, const 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.

Return
miopenStatus_t
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)

miopenDestroyPoolingDescriptor

miopenStatus_t miopenDestroyPoolingDescriptor(miopenPoolingDescriptor_t poolDesc)

Destroys the pooling descriptor object.

Return
miopenStatus_t
Parameters
  • poolDesc: Pooling tensor descriptor type (input)