Simd Library Documentation.

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

Functions to acceleratŠµ layer scale in Synet Framework. More...

Functions

SIMD_API void SimdSynetScaleLayerForward (const float *src, const float *scale, const float *bias, size_t channels, size_t height, size_t width, float *dst, SimdTensorFormatType format, SimdSynetCompatibilityType compatibility)
 This function is used for forward propagation of ScaleLayer. More...
 
SIMD_API void * SimdSynetScale8iInit (size_t batch, size_t channels, size_t spatial, SimdTensorDataType srcType, SimdTensorDataType dstType, SimdTensorFormatType format, SimdSynetCompatibilityType compatibility)
 Initilizes INT8 scale algorithm. More...
 
SIMD_API size_t SimdSynetScale8iInternalBufferSize (const void *context)
 Gets size of internal buffer used inside INT8 scale algorithm. More...
 
SIMD_API void SimdSynetScale8iSetParams (void *context, const float *scale, const float *bias, const float *const *stats)
 Sets scale, bias, parameters of activation function, input/output tensor statistics required for INT8 scale algorithm. More...
 
SIMD_API void SimdSynetScale8iForward (void *context, const uint8_t *src, uint8_t *dst)
 Performs forward propagation of INT8 scale algorithm. More...
 

Detailed Description

Functions to acceleratŠµ layer scale in Synet Framework.

Function Documentation

◆ SimdSynetScaleLayerForward()

void SimdSynetScaleLayerForward ( const float *  src,
const float *  scale,
const float *  bias,
size_t  channels,
size_t  height,
size_t  width,
float *  dst,
SimdTensorFormatType  format,
SimdSynetCompatibilityType  compatibility 
)

This function is used for forward propagation of ScaleLayer.

Algorithm's details (example for NCHW tensor format):

for(c = 0; c < channels; ++c)
    for(h = 0; h < height; ++h)
        for(w = 0; w < width; ++w)
            dst[(c*height + h)*width + w] = src[(c*height + h)*width + w]*scale[c] + (bias ? bias[c] : 0);
Note
This function is used in Synet Framework.
Parameters
[in]src- a pointer to the 32-bit float array with input image tensor. The size of the array is equal to channels * spatial.
[in]scale- a pointer to the 32-bit float array with scale coefficients. The size of the array is equal to channels.
[in]bias- a pointer to the 32-bit float array with bias coefficients. The size of the array is equal to channels. Can be NULL.
[in]channels- a number of channels in the (input/output) image tensor.
[in]height- a height of (input/output) image tensor.
[in]width- a width of (input/output) image tensor.
[out]dst- a pointer to the 32-bit float array with output image tensor. The size of the array is equal to channels * spatial.
[in]format- a format of (input/output) image tensor.
[in]compatibility- a flags of calculation compatibility.

◆ SimdSynetScale8iInit()

void * SimdSynetScale8iInit ( size_t  batch,
size_t  channels,
size_t  spatial,
SimdTensorDataType  srcType,
SimdTensorDataType  dstType,
SimdTensorFormatType  format,
SimdSynetCompatibilityType  compatibility 
)

Initilizes INT8 scale algorithm.

Parameters
[in]batch- a batch size.
[in]channels- a numbeo of channels.
[in]spatial- a spatial image size.
[in]srcType- an input data type (SimdTensorData32f or SimdTensorData8u).
[in]dstType- an output data type (SimdTensorData32f or SimdTensorData8u).
[in]format- a format of (input/output) image tensor.
[in]compatibility- a flags of calculation compatibility.
Returns
a pointer to INT8 scale context. On error it returns NULL. It must be released with using of function SimdRelease. This pointer is used in functions SimdSynetScale8iInternalBufferSize, SimdSynetScale8iSetParams and SimdSynetScale8iForward.

◆ SimdSynetScale8iInternalBufferSize()

size_t SimdSynetScale8iInternalBufferSize ( const void *  context)

Gets size of internal buffer used inside INT8 scale algorithm.

Parameters
[in]context- a pointer to INT8 scale context. It must be created by function SimdSynetScale8iInit and released by function SimdRelease.
Returns
size of internal buffer used inside INT8 scale algorithm.

◆ SimdSynetScale8iSetParams()

void SimdSynetScale8iSetParams ( void *  context,
const float *  scale,
const float *  bias,
const float *const *  stats 
)

Sets scale, bias, parameters of activation function, input/output tensor statistics required for INT8 scale algorithm.

Parameters
[in,out]context- a pointer to INT8 convolution context. It must be created by function SimdSynetScale8iInit and released by function SimdRelease.
[in]scale- a pointer to original (32-bit float point) scale.
[in]bias- a pointer to original (32-bit float point) bias. Can be NULL.
[in]stats- a pointer to pointers with statistics of input(min - stats[0], max - stats[1]) and output(min - stats[2], max - stats[3]) tensors. Can be NULL for subsequent calls of this function.

◆ SimdSynetScale8iForward()

void SimdSynetScale8iForward ( void *  context,
const uint8_t *  src,
uint8_t *  dst 
)

Performs forward propagation of INT8 scale algorithm.

Parameters
[in]context- a pointer to INT8 scale context. It must be created by function SimdSynetScale8iInit and released by function SimdRelease.
[in]src- a pointer to input tensor.
[out]dst- a pointer to output tensor.