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 M, size_t N, size_t K, SimdBool transB, SimdBool constB, SimdBool bias, 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 size_t SimdSynetInnerProduct32fExternalBufferSize (const void *context)
 Gets size of external buffer used in 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 *A, const float *B, float *buf, float *C)
 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  M,
size_t  N,
size_t  K,
SimdBool  transB,
SimdBool  constB,
SimdBool  bias,
SimdConvolutionActivationType  activation 
)

Initilizes FP32 inner product algorithm.

Parameters
[in]M- a height of A and height of C matrices.
[in]N- a width of B and width of C matrices.
[in]K- a width of A and height of B matrices.
[in]transB- a transpose matrix B before multiplication.
[in]constB- a matrix B is constant.
[in]bias- a flag to add bias to output matrix C.
[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, SimdSynetInnerProduct32fExternalBufferSize, 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.

◆ SimdSynetInnerProduct32fExternalBufferSize()

size_t SimdSynetInnerProduct32fExternalBufferSize ( const void *  context)

Gets size of external buffer used in 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 *  A,
const float *  B,
float *  buf,
float *  C 
)

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]A- a pointer to A matrix.
[in]B- a pointer to B matrix. Can be NULL if B is constant matrix. In that case you have to set B (weight) in function SimdSynetInnerProduct16bSetParams.
[out]buf- a pointer to external buffer. The size of the external temporary buffer is determined by function SimdSynetInnerProduct16bExternalBufferSize. Can be NULL (it causes usage of internal buffer).
[out]C- a pointer to output matrix.

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