Pooling

Pooling#

MIOpen: Pooling

Enumerations

enum  miopenIndexType_t {
  miopenIndexUint8 = 0 ,
  miopenIndexUint16 = 1 ,
  miopenIndexUint32 = 2 ,
  miopenIndexUint64 = 3
}
 
enum  miopenPoolingMode_t {
  miopenPoolingMax = 0 ,
  miopenPoolingAverage = 1 ,
  miopenPoolingAverageInclusive = 2
}
 
enum  miopenPoolingWorkspaceIndexMode_t {
  miopenPoolingWorkspaceIndexMask = 0 ,
  miopenPoolingWorkspaceIndexImage = 1
}
 

Functions

 MIOPEN_DECLARE_OBJECT (miopenPoolingDescriptor)
 Creates the miopenPoolingDescriptor_t type. More...
 
miopenStatus_t miopenCreatePoolingDescriptor (miopenPoolingDescriptor_t *poolDesc)
 Creates a pooling layer descriptor. More...
 
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. More...
 
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. More...
 
miopenStatus_t miopenSetPoolingWorkSpaceIndexMode (miopenPoolingDescriptor_t poolDesc, miopenPoolingWorkspaceIndexMode_t workspace_index)
 Set workspace index mode for pooling layer. The default mode is miopenPoolingWorkSpaceIndexMask. More...
 
miopenStatus_t miopenGetPoolingWorkSpaceIndexMode (miopenPoolingDescriptor_t poolDesc, miopenPoolingWorkspaceIndexMode_t *workspace_index)
 Get workspace index mode for pooling layer. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
miopenStatus_t miopenPoolingGetWorkSpaceSize (const miopenTensorDescriptor_t yDesc, size_t *workSpaceSize)
 Get the amount of GPU memory required for pooling. More...
 
miopenStatus_t miopenPoolingGetWorkSpaceSizeV2 (const miopenPoolingDescriptor_t poolDesc, const miopenTensorDescriptor_t yDesc, size_t *workSpaceSize)
 Get the amount of GPU memory required for pooling. More...
 
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. More...
 
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. More...
 
miopenStatus_t miopenDestroyPoolingDescriptor (miopenPoolingDescriptor_t poolDesc)
 Destroys the pooling descriptor object. More...
 

Detailed Description

Enumeration Type Documentation

◆ miopenIndexType_t

MIOpen index datatypes.

Enumerator
miopenIndexUint8 

8-bit unsigned

miopenIndexUint16 

16-bit unsigned

miopenIndexUint32 

32-bit unsigned

miopenIndexUint64 

64-bit unsigned

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

◆ miopenPoolingMode_t

Pooling layer mode

Enumerator
miopenPoolingMax 

Maximum pooling

miopenPoolingAverage 

Average pooling

miopenPoolingAverageInclusive 

Inclusive Average pooling

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

◆ miopenPoolingWorkspaceIndexMode_t

Pooling layer workspace index mode. miopenPoolingWorkspaceIndexMask mode records indices indicating the max values' positions in the filter/mask. miopenPoolingWorkspaceIndexImage mode records indices indicating the max values' positions in the image.

Enumerator
miopenPoolingWorkspaceIndexMask 

Use mask indices, 2D pooling only

miopenPoolingWorkspaceIndexImage 

Use image indices

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

Function Documentation

◆ MIOPEN_DECLARE_OBJECT()

MIOPEN_DECLARE_OBJECT ( miopenPoolingDescriptor  )

Creates the miopenPoolingDescriptor_t type.

Pooling descriptor is an object that allows the user to specify the dimension sizes of the pooling windows, paddings, strides, and pooling mode.

◆ miopenCreatePoolingDescriptor()

miopenStatus_t miopenCreatePoolingDescriptor ( miopenPoolingDescriptor_t *  poolDesc)

Creates a pooling layer descriptor.

Parameters
poolDescPointer to a pooling layer descriptor (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ miopenDestroyPoolingDescriptor()

miopenStatus_t miopenDestroyPoolingDescriptor ( miopenPoolingDescriptor_t  poolDesc)

Destroys the pooling descriptor object.

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

◆ 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
poolDescPointer to a pooling layer descriptor (input)
modePooling mode enum (output)
windowHeightInput window height dimension (output)
windowWidthInput window width dimension (output)
pad_hNumber of elements to pad height (output)
pad_wNumber of elements to pad width (output)
stride_hVertical stride (output)
stride_wHorizontal stride (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
poolDescPointer to a pooling layer descriptor (input)
nbDimsRequestedDimension of the expected pooling descriptor (input)
modePooling mode enum (output)
nbDimsActual dimension of the pooling descriptor (output)
windowDimAArray of input window dimensions with length equal to or larger than dimsRequested (output)
padAArray of number of elements to padding with length equal to or larger than dimsRequested (output)
stridesAArray of stride parameter with length equal to or larger than dimsRequested (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
poolDescPointer to a pooling layer descriptor (input)
tensorDescInput tensor descriptor (input)
nMini-batch dim (output)
cNumber of channels (output)
hHeights of input map (output)
wWidth of input map (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
poolDescPointer to a pooling layer descriptor (input)
index_typeIndex type (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
poolDescPointer to a pooling layer descriptor (input)
tensorDescInput tensor descriptor (input)
dimsDimension of the pooling (input)
tensorDimArrArray of tensor dimension (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ miopenGetPoolingWorkSpaceIndexMode()

miopenStatus_t miopenGetPoolingWorkSpaceIndexMode ( miopenPoolingDescriptor_t  poolDesc,
miopenPoolingWorkspaceIndexMode_t workspace_index 
)

Get workspace index mode for pooling layer.

Parameters
poolDescPointer to a pooling layer descriptor (input)
workspace_indexWorkspace index mode (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
handleMIOpen handle (input)
poolDescDescriptor for pooling layer (input)
alphaFloating point scaling factor, allocated on the host (input)
yDescTensor descriptor for output data tensor y (input)
yData tensor y (input)
dyDescTensor descriptor for data input tensor dy (input)
dyData delta tensor dy (input)
xDescTensor descriptor for output data tensor x (input)
xData tensor x (output)
betaFloating point shift factor, allocated on the host (input)
dxDescTensor descriptor for tensor dx (input)
dxWeights delta tensor dx (output)
workSpacePointer to user allocated workspace (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
handleMIOpen handle (input)
poolDescDescriptor for pooling layer (input)
alphaFloating point scaling factor, allocated on the host (input)
xDescTensor descriptor for data input tensor x (input)
xData tensor x (input)
betaFloating point shift factor, allocated on the host (input)
yDescTensor descriptor for output data tensor y (input)
yData tensor y (output)
do_backwardBoolean to toggle save data in workspace for backwards pass (input)
workSpacePointer user allocated memory (input)
workSpaceSizeSize in bytes of the memory needed (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
yDescDescriptor for pooling layer (input)
workSpaceSizePointer to workSpaceSize (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
poolDescPointer to a pooling layer descriptor (input)
yDescDescriptor for pooling layer (input)
workSpaceSizePointer to workSpaceSize (output)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
poolDescPointer to a pooling layer descriptor (output)
modePooling mode enum (input)
windowHeightInput window height dimension (input)
windowWidthInput window width dimension (input)
pad_hNumber of elements to pad height (input)
pad_wNumber of elements to pad width (input)
stride_hVertical stride (input)
stride_wHorizontal stride (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
poolDescPointer to a pooling layer descriptor (input/output)
modePooling mode enum (input)
nbDimsDimension of the pooling (input)
windowDimAArray of input window dimensions with length equal to or larger than dimsRequested (input)
padAArray of number of elements to padding with length equal to or larger than dimsRequested (input)
stridesAArray of stride parameter with length equal to or larger than dimsRequested (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ 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
poolDescPointer to a pooling layer descriptor (input)
index_typeIndex type (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.

◆ miopenSetPoolingWorkSpaceIndexMode()

miopenStatus_t miopenSetPoolingWorkSpaceIndexMode ( miopenPoolingDescriptor_t  poolDesc,
miopenPoolingWorkspaceIndexMode_t  workspace_index 
)

Set workspace index mode for pooling layer. The default mode is miopenPoolingWorkSpaceIndexMask.

Parameters
poolDescPointer to a pooling layer descriptor (input/output)
workspace_indexWorkspace index mode (input)
Returns
miopenStatus_t
Examples
/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-miopen/checkouts/docs-6.2.4/include/miopen/miopen.h.