Simd Library Documentation.

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

Add accelerated functions used in Synet Framework. More...

Functions

SIMD_API void * SimdSynetAdd16bInit (const size_t *aShape, size_t aCount, SimdTensorDataType aType, const size_t *bShape, size_t bCount, SimdTensorDataType bType, SimdTensorDataType dstType, SimdTensorFormatType format)
 Initilizes add algorithm. More...
 
SIMD_API void SimdSynetAdd16bForward (void *context, const uint8_t *a, const uint8_t *b, uint8_t *dst)
 Performs forward propagation of add algorithm. More...
 
SIMD_API void SimdSynetAddBias (const float *bias, size_t channels, size_t spatial, float *dst, SimdTensorFormatType format)
 Adds a bias to given vector. More...
 
SIMD_API void SimdSynetAdd8i (const uint8_t *aData, const float *aScale, const float *aShift, const uint8_t *bData, const float *bScale, const float *bShift, uint8_t *cData, const float *cScale, const float *cShift, size_t batch, size_t channels, size_t spatial, SimdTensorFormatType format, SimdSynetCompatibilityType compatibility)
 Adds two INT8 tensors. More...
 

Detailed Description

Add accelerated functions used in Synet Framework.

Function Documentation

◆ SimdSynetAdd16bInit()

void * SimdSynetAdd16bInit ( const size_t *  aShape,
size_t  aCount,
SimdTensorDataType  aType,
const size_t *  bShape,
size_t  bCount,
SimdTensorDataType  bType,
SimdTensorDataType  dstType,
SimdTensorFormatType  format 
)

Initilizes add algorithm.

Parameters
[in]aShape- a pointer to shape of input A tensor.
[in]aCount- a count of dimensions of input A tensor.
[in]aType- a type of input A tensor. Can be FP32 of BF16.
[in]bShape- a pointer to shape of input B tensor.
[in]bCount- a count of dimensions of input B tensor.
[in]bType- a type of input B tensor. Can be FP32 of BF16.
[in]dstType- a type of output tensor. Can be FP32 of BF16.
[in]format- a format of input / output tensors.
Returns
a pointer to add context. On error it returns NULL. It must be released with using of function SimdRelease. This pointer is used in function SimdSynetAdd16bForward.

◆ SimdSynetAdd16bForward()

void SimdSynetAdd16bForward ( void *  context,
const uint8_t *  a,
const uint8_t *  b,
uint8_t *  dst 
)

Performs forward propagation of add algorithm.

Parameters
[in]context- a pointer to add context. It must be created by function SimdSynetAdd16bInit and released by function SimdRelease.
[in]a- a pointer to input A tensor.
[in]b- a pointer to input B tensor.
[out]dst- a pointer to output tensor.

◆ SimdSynetAddBias()

void SimdSynetAddBias ( const float *  bias,
size_t  channels,
size_t  spatial,
float *  dst,
SimdTensorFormatType  format 
)

Adds a bias to given vector.

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

for(c = 0; c < channels; ++c)
    for(j = 0; j < spatial; ++j)
         dst[c*spatial + s] += bias[c];
Note
This function is used in Synet Framework.
Parameters
[in]bias- a pointer to the 32-bit float array with bias coefficients. The size of the array is eqial to channels.
[in]channels- a number of channels in the image tensor.
[in]spatial- a spatial size of image tensor.
[in,out]dst- a pointer to cumulative 32-bit image tensor. The size of the array is equal to channels * spatial.
[in]format- a format of image tensor.

◆ SimdSynetAdd8i()

void SimdSynetAdd8i ( const uint8_t *  aData,
const float *  aScale,
const float *  aShift,
const uint8_t *  bData,
const float *  bScale,
const float *  bShift,
uint8_t *  cData,
const float *  cScale,
const float *  cShift,
size_t  batch,
size_t  channels,
size_t  spatial,
SimdTensorFormatType  format,
SimdSynetCompatibilityType  compatibility 
)

Adds two INT8 tensors.

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

for(b = 0; b < batch; ++b)
    for(c = 0; c < channels; ++c)
        for(s = 0; s < spatial; ++s)
        {
             offs = (b*channels + c)*spatial + s;
             A = aData[offs]*aScale[c] + aShift[c]; 
             B = bData[offs]*bScale[c] + bShift[c];
             cData[offs] = round((A + B)*cScale[c] + cShift[c]);
        }
Note
This function is used in Synet Framework.
Parameters
[in]aData- a pointer to the first input 8-bit integer tensor.
[in]aScale- a pointer to the 32-bit float array with scale coefficients of the first input tensor.
[in]aShift- a pointer to the 32-bit float array with shift coefficients of the first input tensor.
[in]bData- a pointer to the second input 8-bit integer tensor.
[in]bScale- a pointer to the 32-bit float array with scale coefficients of the second input tensor.
[in]bShift- a pointer to the 32-bit float array with shift coefficients of the second input tensor.
[out]cData- a pointer to the output 8-bit integer tensor.
[in]cScale- a pointer to the 32-bit float array with scale coefficients of the output tensor.
[in]cShift- a pointer to the 32-bit float array with shift coefficients of the output tensor.
[in]batch- a batch size of input and output image tensors.
[in]channels- a number of channels in input and output image tensors.
[in]spatial- a spatial size of input and output image tensors.
[in]format- a format of input and output image tensors.
[in]compatibility- a flags of calculation compatibility.