Simd Library Documentation.

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

Functions to acceleratŠµ InnerProductLayer in Synet Framework. More...

Functions

SIMD_API void * SimdSynetInnerProduct32fInit (size_t batch, size_t input, size_t output, SimdBool transpose, SimdConvolutionActivationType activation)
 Initilizes FP32 inner product algorithm. More...
 
SIMD_API size_t SimdSynetInnerProduct32fInternalBufferSize (const void *context)
 Gets size of internal buffer used inside FP32 inner product algorithm. More...
 
SIMD_API void SimdSynetInnerProduct32fSetParams (void *context, const float *weight, SimdBool *internal, const float *bias, const float *params)
 Sets weights, beases and parameters of activation function required for FP32 inner product algorithm. More...
 
SIMD_API void SimdSynetInnerProduct32fForward (void *context, const float *src, float *dst)
 Performs forward propagation of FP32 inner product algorithm. More...
 
SIMD_API void SimdSynetInnerProductLayerForward (const float *src, const float *weight, const float *bias, size_t count, size_t size, float *dst)
 This function is used for forward propagation of InnerProductLayer. More...
 
SIMD_API void SimdSynetInnerProduct8i (size_t M, size_t N, size_t K, const uint8_t *src, const int8_t *weight, int32_t *dst, SimdSynetCompatibilityType compatibility)
 This function is used for INT8 forward propagation of InnerProductLayer. More...
 

Detailed Description

Functions to acceleratŠµ InnerProductLayer in Synet Framework.

Function Documentation

◆ SimdSynetInnerProduct32fInit()

void * SimdSynetInnerProduct32fInit ( size_t  batch,
size_t  input,
size_t  output,
SimdBool  transpose,
SimdConvolutionActivationType  activation 
)

Initilizes FP32 inner product algorithm.

Parameters
[in]batch- a batch size.
[in]input- a input vector size.
[in]output- a output vector size.
[in]transpose- a flag of transposing of weight matrix.
[in]activation- an activation function type used after inner product.
Returns
a pointer to FP32 inner product context. On error it returns NULL. It must be released with using of function SimdRelease. This pointer is used in functions SimdSynetInnerProduct32fInternalBufferSize, :SimdSynetInnerProduct32fSetParams and SimdSynetInnerProduct32fForward.

◆ SimdSynetInnerProduct32fInternalBufferSize()

size_t SimdSynetInnerProduct32fInternalBufferSize ( const void *  context)

Gets size of internal buffer used inside FP32 inner product algorithm.

Parameters
[in]context- a pointer to FP32 inner product context. It must be created by function SimdSynetInnerProduct32fInit and released by function SimdRelease.
Returns
size of internal buffer used inside FP32 inner product algorithm.

◆ SimdSynetInnerProduct32fSetParams()

void SimdSynetInnerProduct32fSetParams ( void *  context,
const float *  weight,
SimdBool internal,
const float *  bias,
const float *  params 
)

Sets weights, beases and parameters of activation function required for FP32 inner product algorithm.

Parameters
[in,out]context- a pointer to FP32 inner product context. It must be created by function SimdSynetInnerProduct32fInit and released by function SimdRelease.
[in]weight- a pointer to inner product weights.
[out]internal- a flag signalized that weight is stored in the internal buffer. Can be NULL.
[in]bias- a pointer to bias. Can be NULL.
[in]params- a pointer to parameters of activation functions (see SimdConvolutionActivationType). Can be NULL.

◆ SimdSynetInnerProduct32fForward()

void SimdSynetInnerProduct32fForward ( void *  context,
const float *  src,
float *  dst 
)

Performs forward propagation of FP32 inner product algorithm.

Parameters
[in]context- a pointer to FP32 inner product context. It must be created by function SimdSynetInnerProduct32fInit and released by function SimdRelease.
[in]src- a pointer to input tensor.
[out]dst- a pointer to output tensor.

◆ SimdSynetInnerProductLayerForward()

void SimdSynetInnerProductLayerForward ( const float *  src,
const float *  weight,
const float *  bias,
size_t  count,
size_t  size,
float *  dst 
)

This function is used for forward propagation of InnerProductLayer.

Algorithm's details:

for(i = 0; i < count; ++i)
{
    dst[i] = (bias ? bias[i] : 0);
    for(j = 0; j < size; ++j)
       dst[i] += src[j]*weight[i*size + j];
}
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 size.
[in]weight- a pointer to the 32-bit float array with weight coefficients. The size of the array must be equal to count*size.
[in]bias- a pointer to the 32-bit float array with bias coefficients. The size of the array must be equal to count. Can be NULL.
[in]count- a size of output array.
[in]size- a size of input array.
[out]dst- a pointer to the output 32-bit float array. The size of the array must be equal to count.

◆ SimdSynetInnerProduct8i()

void SimdSynetInnerProduct8i ( size_t  M,
size_t  N,
size_t  K,
const uint8_t *  src,
const int8_t *  weight,
int32_t *  dst,
SimdSynetCompatibilityType  compatibility 
)

This function is used for INT8 forward propagation of InnerProductLayer.

Algorithm's details:

for (i = 0; i < M; ++i)
{
    for (j = 0; j < N; ++j)
    {
        sum = 0;
        for (k = 0; k < K; ++k)
            sum += src[i * K + k] * weight[j * K + k];
        dst[i*N + j] = sum;
    }
}
Note
This function is used in Synet Framework.
Parameters
[in]M- a batch size.
[in]N- an output size.
[in]K- an input size.
[in]src- a pointer to the input 8-bit unsigned integer array. The size of the array must be equal to M*K.
[in]weight- a pointer to the 8-bit signed integer array with weight. The size of the array must be equal to N*K.
[out]dst- a pointer to the output 32-bit integer array. The size of the array must be equal to M*N.
[in]compatibility- a flags of calculation compatibility.