Simd Library Documentation.

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

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

Functions

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...
 
SIMD_API void SimdSynetEltwiseLayerForward (float const *const *src, const float *weight, size_t count, size_t size, SimdSynetEltwiseOperationType type, float *dst)
 This function is used for forward propagation of EltwiseLayer. More...
 
SIMD_API void SimdSynetLrnLayerCrossChannels (const float *src, size_t half, size_t channels, size_t spatial, const float *k, float *dst, SimdTensorFormatType format)
 This function is used for forward propagation of LrnLayer (cross channels normalization). More...
 
SIMD_API void SimdSynetShuffleLayerForward (const float *src0, const float *src1, size_t channels0, size_t channels1, size_t spatial, float *dst0, float *dst1, SimdTensorFormatType format, int type)
 This function is used for forward propagation of ShuffleLayer. More...
 
SIMD_API void SimdSynetSoftmaxLayerForward (const float *src, size_t outer, size_t count, size_t inner, float *dst)
 This function is used for forward propagation of SoftmaxLayer. More...
 
SIMD_API void SimdSynetUnaryOperation32f (const float *src, size_t size, SimdSynetUnaryOperation32fType type, float *dst)
 This function is used for forward propagation of UnaryOperationLayer. More...
 

Detailed Description

Other accelerated functions used in Synet Framework.

Function Documentation

◆ 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.

◆ SimdSynetEltwiseLayerForward()

void SimdSynetEltwiseLayerForward ( float const *const *  src,
const float *  weight,
size_t  count,
size_t  size,
SimdSynetEltwiseOperationType  type,
float *  dst 
)

This function is used for forward propagation of EltwiseLayer.

Algorithm's details for SimdSynetEltwiseOperationProduct:

for(j = 0; j < size; ++j)
    dst[j] = 1;
for(i = 0; i < count; ++i)
    for(j = 0; j < size; ++j)
        dst[j] *= src[i][j];

Algorithm's details for SimdSynetEltwiseOperationSum:

for(j = 0; j < size; ++j)
    dst[j] = 0;
for(i = 0; i < count; ++i)
    for(j = 0; j < size; ++j)
        dst[j] += src[i][j]*weight[i];

Algorithm's details for SimdSynetEltwiseOperationMax:

for(j = 0; j < size; ++j)
    dst[j] = -FLT_MAX;
for(i = 0; i < count; ++i)
    for(j = 0; j < size; ++j)
        dst[j] = Max(dst[j], src[i][j]);

Algorithm's details for SimdSynetEltwiseOperationMin:

for(j = 0; j < size; ++j)
    dst[j] = FLT_MAX;
for(i = 0; i < count; ++i)
    for(j = 0; j < size; ++j)
        dst[j] = Min(dst[j], src[i][j]);
Note
This function is used in Synet Framework.
Parameters
[in]src- a pointer to poitres to the input 32-bit float arrays.
[in]weight- a pointer to the 32-bit float array with sum coefficients. It is need only for SimdSynetEltwiseOperationSum operation type otherwise it can be NULL.
[in]count- a count of input arrays. Must be at least 2.
[in]size- a size of the input and output arrays.
[in]type- a type of operation (see SimdSynetEltwiseOperationType).
[out]dst- a pointer to the output 32-bit float array.

◆ SimdSynetLrnLayerCrossChannels()

void SimdSynetLrnLayerCrossChannels ( const float *  src,
size_t  half,
size_t  channels,
size_t  spatial,
const float *  k,
float *  dst,
SimdTensorFormatType  format 
)

This function is used for forward propagation of LrnLayer (cross channels normalization).

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

for(c = 0; c < channels; ++c)
    for(s = 0; s < spatial; ++s)
    {
        lo = Max(0, c - half);
        hi = Min(channels, c + half + 1);
        sum = 0;
        for(i = lo; i < ln; ++i)
            sum += Square(src[i*spatial + s]);
        dst[c*spatial + s] = src[c*spatial + s]*Pow(k[0] + sum*k[1], k[2]);
    }
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]half- a local normalization half size.
[in]channels- a number of channels in the (input/output) image tensor
[in]spatial- a spatial size of (input/output) image tensor.
[in]k- a pointer to the 32-bit float array with 3 coefficients (see algorithm details).
[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.

◆ SimdSynetShuffleLayerForward()

void SimdSynetShuffleLayerForward ( const float *  src0,
const float *  src1,
size_t  channels0,
size_t  channels1,
size_t  spatial,
float *  dst0,
float *  dst1,
SimdTensorFormatType  format,
int  type 
)

This function is used for forward propagation of ShuffleLayer.

Note
This function is used in Synet Framework.
Parameters
[in]src0- a pointer to the 32-bit float array with the first input image tensor.
[in]src1- a pointer to the 32-bit float array with the second input image tensor.
[in]channels0- a number of channels in the first input (type == 0) or output (type == 1) image tensor. It must be even number.
[in]channels1- a number of channels in the second input (type == 0) or output (type == 1) image tensor. It must be even number.
[in]spatial- a spatial size of (input/output) image tensors.
[out]dst0- a pointer to the 32-bit float array with the first output image tensor.
[out]dst1- a pointer to the 32-bit float array with the second output image tensor.
[in]format- a format of (input/output) image tensors.
[in]type- a shuffle type (it can be 0 or 1).

◆ SimdSynetSoftmaxLayerForward()

void SimdSynetSoftmaxLayerForward ( const float *  src,
size_t  outer,
size_t  count,
size_t  inner,
float *  dst 
)

This function is used for forward propagation of SoftmaxLayer.

Note
This function is used in Synet Framework.
Parameters
[in]src- a pointer to the input 32-bit float array. The size of the array must be equal to outer*count*inner.
[in]outer- an outer size of input and output arrays.
[in]count- a size of softmax dimmension.
[in]inner- an inner size of input and output arrays.
[out]dst- a pointer to the output 32-bit float array. The size of the array must be equal to outer*count*inner.

◆ SimdSynetUnaryOperation32f()

void SimdSynetUnaryOperation32f ( const float *  src,
size_t  size,
SimdSynetUnaryOperation32fType  type,
float *  dst 
)

This function is used for forward propagation of UnaryOperationLayer.

Note
This function is used in Synet Framework.
Parameters
[in]src- a pointer to poitres to the input 32-bit float arrays.
[in]size- a size of the input and output arrays.
[in]type- an unary operation type (see SimdSynetUnaryOperation32fType).
[out]dst- a pointer to the output 32-bit float array.