Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub
PoolingLayer functions

Functions to accelerate PoolingLayer in Synet Framework. More...

Functions

SIMD_API void SimdSynetPoolingAverage (const float *src, size_t srcC, size_t srcH, size_t srcW, size_t kernelY, size_t kernelX, size_t strideY, size_t strideX, size_t padY, size_t padX, float *dst, size_t dstH, size_t dstW, SimdBool excludePad, SimdTensorFormatType format)
 Performs 2D average pooling for an FP32 tensor. More...
 
SIMD_API void SimdSynetPoolingMax32f (const float *src, size_t srcC, size_t srcH, size_t srcW, size_t kernelC, size_t kernelY, size_t kernelX, size_t strideC, size_t strideY, size_t strideX, size_t padC, size_t padY, size_t padX, float *dst, size_t dstC, size_t dstH, size_t dstW, SimdTensorFormatType format)
 Performs 2D or 3D max pooling for an FP32 tensor. More...
 
SIMD_API void SimdSynetPoolingMax16b (const uint16_t *src, size_t srcC, size_t srcH, size_t srcW, size_t kernelY, size_t kernelX, size_t strideY, size_t strideX, size_t padY, size_t padX, uint16_t *dst, size_t dstH, size_t dstW, SimdTensorFormatType format)
 Performs 2D max pooling for a BF16 tensor. More...
 
SIMD_API void SimdSynetPoolingMax8u (const uint8_t *src, size_t srcC, size_t srcH, size_t srcW, size_t kernelY, size_t kernelX, size_t strideY, size_t strideX, size_t padY, size_t padX, uint8_t *dst, size_t dstH, size_t dstW, SimdTensorFormatType format)
 Performs 2D max pooling for a UINT8 tensor. More...
 

Detailed Description

Functions to accelerate PoolingLayer in Synet Framework.

Function Documentation

◆ SimdSynetPoolingAverage()

void SimdSynetPoolingAverage ( const float *  src,
size_t  srcC,
size_t  srcH,
size_t  srcW,
size_t  kernelY,
size_t  kernelX,
size_t  strideY,
size_t  strideX,
size_t  padY,
size_t  padX,
float *  dst,
size_t  dstH,
size_t  dstW,
SimdBool  excludePad,
SimdTensorFormatType  format 
)

Performs 2D average pooling for an FP32 tensor.

For every output position the pooling window starts at (dstY*strideY - padY, dstX*strideX - padX), is clipped by input boundaries and is averaged independently for every channel. If excludePad is SimdTrue, the divisor is the clipped window area; otherwise it is kernelY*kernelX. It supports SimdTensorFormatNchw and SimdTensorFormatNhwc.

Algorithm's details:

for(c = 0; c < srcC; ++c)
    for(dy = 0; dy < dstH; ++dy)
        for(dx = 0; dx < dstW; ++dx)
        {
            yBeg = Max(0, dy*strideY - padY);
            yEnd = Min(srcH, dy*strideY - padY + kernelY);
            xBeg = Max(0, dx*strideX - padX);
            xEnd = Min(srcW, dx*strideX - padX + kernelX);
            sum = 0;
            for(sy = yBeg; sy < yEnd; ++sy)
                for(sx = xBeg; sx < xEnd; ++sx)
                    sum += src[c, sy, sx];
            dst[c, dy, dx] = sum / (excludePad ? (yEnd - yBeg)*(xEnd - xBeg) : kernelY*kernelX);
        }
Note
This function is used in Synet Framework.
Parameters
[in]src- a pointer to the input FP32 tensor. The size of the array must be equal to srcC*srcH*srcW.
[in]srcC- a number of input and output channels.
[in]srcH- an input height.
[in]srcW- an input width.
[in]kernelY- a height of the pooling kernel.
[in]kernelX- a width of the pooling kernel.
[in]strideY- a y-stride of the pooling.
[in]strideX- a x-stride of the pooling.
[in]padY- a pad to the top of the input image.
[in]padX- a pad to the left of the input image.
[out]dst- a pointer to the output FP32 tensor. The size of the array must be equal to srcC*dstH*dstW.
[in]dstH- an output height.
[in]dstW- an output width.
[in]excludePad- a flag that excludes padded positions from average value calculation.
[in]format- a format of input and output tensor. It can be SimdTensorFormatNchw or SimdTensorFormatNhwc.

◆ SimdSynetPoolingMax32f()

void SimdSynetPoolingMax32f ( const float *  src,
size_t  srcC,
size_t  srcH,
size_t  srcW,
size_t  kernelC,
size_t  kernelY,
size_t  kernelX,
size_t  strideC,
size_t  strideY,
size_t  strideX,
size_t  padC,
size_t  padY,
size_t  padX,
float *  dst,
size_t  dstC,
size_t  dstH,
size_t  dstW,
SimdTensorFormatType  format 
)

Performs 2D or 3D max pooling for an FP32 tensor.

If kernelC == 1, strideC == 1, padC == 0 and srcC == dstC, the function performs ordinary 2D max pooling independently for every channel. Otherwise it also pools across channels, using kernelC, strideC, padC and dstC. Pooling windows are clipped by input boundaries. It supports SimdTensorFormatNchw and SimdTensorFormatNhwc.

Note
This function is used in Synet Framework.
Parameters
[in]src- a pointer to the input FP32 tensor. The size of the array must be equal to srcC*srcH*srcW.
[in]srcC- a number of input channels.
[in]srcH- an input height.
[in]srcW- an input width.
[in]kernelC- a channel size of the pooling kernel in 3D case. In 2D case it must be equal to 1.
[in]kernelY- a height of the pooling kernel.
[in]kernelX- a width of the pooling kernel.
[in]strideC- a c-stride of the pooling in 3D case. In 2D case it must be equal to 1.
[in]strideY- a y-stride of the pooling.
[in]strideX- a x-stride of the pooling.
[in]padC- a channel pad before the first input channel.
[in]padY- a pad to the top of the input image.
[in]padX- a pad to the left of the input image.
[out]dst- a pointer to the output FP32 tensor. The size of the array must be equal to dstC*dstH*dstW.
[in]dstC- a number of output channels.
[in]dstH- an output height.
[in]dstW- an output width.
[in]format- a format of input and output tensor. It can be SimdTensorFormatNchw or SimdTensorFormatNhwc.

◆ SimdSynetPoolingMax16b()

void SimdSynetPoolingMax16b ( const uint16_t *  src,
size_t  srcC,
size_t  srcH,
size_t  srcW,
size_t  kernelY,
size_t  kernelX,
size_t  strideY,
size_t  strideX,
size_t  padY,
size_t  padX,
uint16_t *  dst,
size_t  dstH,
size_t  dstW,
SimdTensorFormatType  format 
)

Performs 2D max pooling for a BF16 tensor.

For every output position the pooling window is clipped by input boundaries and the maximum value is calculated independently for every channel. BF16 values are compared in FP32 domain and stored back as BF16. It supports SimdTensorFormatNchw and SimdTensorFormatNhwc.

Note
This function is used in Synet Framework.
Parameters
[in]src- a pointer to the input BF16 tensor. The size of the array must be equal to srcC*srcH*srcW.
[in]srcC- a number of input and output channels.
[in]srcH- an input height.
[in]srcW- an input width.
[in]kernelY- a height of the pooling kernel.
[in]kernelX- a width of the pooling kernel.
[in]strideY- a y-stride of the pooling.
[in]strideX- a x-stride of the pooling.
[in]padY- a pad to the top of the input image.
[in]padX- a pad to the left of the input image.
[out]dst- a pointer to the output BF16 tensor. The size of the array must be equal to srcC*dstH*dstW.
[in]dstH- an output height.
[in]dstW- an output width.
[in]format- a format of input and output tensor. It can be SimdTensorFormatNchw or SimdTensorFormatNhwc.

◆ SimdSynetPoolingMax8u()

void SimdSynetPoolingMax8u ( const uint8_t *  src,
size_t  srcC,
size_t  srcH,
size_t  srcW,
size_t  kernelY,
size_t  kernelX,
size_t  strideY,
size_t  strideX,
size_t  padY,
size_t  padX,
uint8_t *  dst,
size_t  dstH,
size_t  dstW,
SimdTensorFormatType  format 
)

Performs 2D max pooling for a UINT8 tensor.

For every output position the pooling window is clipped by input boundaries and the maximum value is calculated independently for every channel. It supports SimdTensorFormatNchw and SimdTensorFormatNhwc.

Note
This function is used in Synet Framework.
Parameters
[in]src- a pointer to the input UINT8 tensor. The size of the array must be equal to srcC*srcH*srcW.
[in]srcC- a number of input and output channels.
[in]srcH- an input height.
[in]srcW- an input width.
[in]kernelY- a height of the pooling kernel.
[in]kernelX- a width of the pooling kernel.
[in]strideY- a y-stride of the pooling.
[in]strideX- a x-stride of the pooling.
[in]padY- a pad to the top of the input image.
[in]padX- a pad to the left of the input image.
[out]dst- a pointer to the output UINT8 tensor. The size of the array must be equal to srcC*dstH*dstW.
[in]dstH- an output height.
[in]dstW- an output width.
[in]format- a format of input and output tensor. It can be SimdTensorFormatNchw or SimdTensorFormatNhwc.