A framework to accelerate DynamicQuantizedInnerProductLayer in Synet Framework. More...
Functions | |
| SIMD_API void * | SimdSynetDynamicQuantizedInnerProduct32fInit (size_t M, size_t N, size_t K, SimdBool bias, SimdConvolutionActivationType activation) |
| Initializes dynamic quantized inner product (matrix multiplication) algorithm for FP32 input, INT8 weight and FP32 output. More... | |
| SIMD_API size_t | SimdSynetDynamicQuantizedInnerProduct32fInternalBufferSize (const void *context) |
| Gets size in bytes of internal buffers allocated by dynamic quantized inner product context. More... | |
| SIMD_API size_t | SimdSynetDynamicQuantizedInnerProduct32fExternalBufferSize (const void *context) |
| Gets size in bytes of external temporary buffer required for dynamic quantized inner product. More... | |
| SIMD_API const char * | SimdSynetDynamicQuantizedInnerProduct32fInfo (const void *context) |
| Gets description of selected dynamic quantized inner product implementation. More... | |
| SIMD_API void | SimdSynetDynamicQuantizedInnerProduct32fSetParams (void *context, const int8_t *weight, const float *scale, const float *bias, const float *params) |
| Sets constant matrix B, bias and dynamic quantization parameters for quantized inner product. More... | |
| SIMD_API void * | SimdSynetDynamicQuantizedInnerProduct16bInit (size_t M, size_t N, size_t K, SimdTensorDataType typeA, SimdTensorDataType typeB, SimdTensorDataType typeC, SimdBool constB, SimdBool bias, SimdConvolutionActivationType activation, SimdBool avoidOverflow) |
| Initializes dynamic quantized inner product (matrix multiplication) algorithm for FP32/BF16 input, FP32/BF16/INT8 weight and FP32/BF16 output. More... | |
| SIMD_API size_t | SimdSynetDynamicQuantizedInnerProduct16bInternalBufferSize (const void *context) |
| Gets the size in bytes of internal storage used by a dynamic quantized inner-product context. More... | |
| SIMD_API size_t | SimdSynetDynamicQuantizedInnerProduct16bExternalBufferSize (const void *context) |
| Gets number of bytes required for external temporary buffer. More... | |
| SIMD_API const char * | SimdSynetDynamicQuantizedInnerProduct16bInfo (const void *context) |
| Gets a short description of the selected dynamic quantized inner-product implementation. More... | |
| SIMD_API void | SimdSynetDynamicQuantizedInnerProduct16bSetParams (void *context, const uint8_t *weight, const float *scale, const float *bias, const float *params) |
| Sets weights, bias and activation parameters for dynamic quantized inner product. More... | |
| SIMD_API void | SimdSynetDynamicQuantizedInnerProduct16bForward (void *context, const uint8_t *A, const uint8_t *B, uint8_t *buf, uint8_t *C) |
| Performs dynamic quantized inner-product forward propagation. More... | |
Detailed Description
A framework to accelerate DynamicQuantizedInnerProductLayer in Synet Framework.
Function Documentation
◆ SimdSynetDynamicQuantizedInnerProduct32fInit()
| void * SimdSynetDynamicQuantizedInnerProduct32fInit | ( | size_t | M, |
| size_t | N, | ||
| size_t | K, | ||
| SimdBool | bias, | ||
| SimdConvolutionActivationType | activation | ||
| ) |
Initializes dynamic quantized inner product (matrix multiplication) algorithm for FP32 input, INT8 weight and FP32 output.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct32f.
- 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] bias - a flag to add bias to output matrix C. [in] activation - an activation function type applied after the rest operations.
- Returns
- a pointer to quantized inner product context. On error it returns NULL. It must be released with using of function SimdRelease. This pointer is used in functions SimdSynetDynamicQuantizedInnerProduct32fInternalBufferSize, SimdSynetDynamicQuantizedInnerProduct32fExternalBufferSize, SimdSynetDynamicQuantizedInnerProduct32fInfo, SimdSynetDynamicQuantizedInnerProduct32fSetParams and SimdSynetDynamicQuantizedInnerProduct32fForward.
◆ SimdSynetDynamicQuantizedInnerProduct32fInternalBufferSize()
| size_t SimdSynetDynamicQuantizedInnerProduct32fInternalBufferSize | ( | const void * | context | ) |
Gets size in bytes of internal buffers allocated by dynamic quantized inner product context.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct32f.
- Parameters
-
[in] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct32fInit and released by function SimdRelease.
- Returns
- size in bytes of internal buffers used inside the algorithm.
◆ SimdSynetDynamicQuantizedInnerProduct32fExternalBufferSize()
| size_t SimdSynetDynamicQuantizedInnerProduct32fExternalBufferSize | ( | const void * | context | ) |
Gets size in bytes of external temporary buffer required for dynamic quantized inner product.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct32f.
- Parameters
-
[in] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct32fInit and released by function SimdRelease.
- Returns
- size in bytes of external temporary buffer required by SimdSynetDynamicQuantizedInnerProduct32fForward.
◆ SimdSynetDynamicQuantizedInnerProduct32fInfo()
| const char * SimdSynetDynamicQuantizedInnerProduct32fInfo | ( | const void * | context | ) |
Gets description of selected dynamic quantized inner product implementation.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct32f.
- Parameters
-
[in] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct32fInit and released by function SimdRelease.
- Returns
- string with description of selected implementation (extension and algorithm name).
◆ SimdSynetDynamicQuantizedInnerProduct32fSetParams()
| void SimdSynetDynamicQuantizedInnerProduct32fSetParams | ( | void * | context, |
| const int8_t * | weight, | ||
| const float * | scale, | ||
| const float * | bias, | ||
| const float * | params | ||
| ) |
Sets constant matrix B, bias and dynamic quantization parameters for quantized inner product.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct32f.
- Parameters
-
[in,out] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct32fInit and released by function SimdRelease. [in] weight - a pointer to constant INT8 B matrix. The size of the array must be equal to K * N; [in] scale - a pointer to per-output-channel FP32 scales of B matrix. The size of the array must be equal to N. [in] bias - a pointer to per-output-channel FP32 bias. Can be NULL. Otherwise the size of the array must be equal to N. [in] params - a pointer to FP32 activation parameters (see SimdConvolutionActivationType). Can be NULL.
◆ SimdSynetDynamicQuantizedInnerProduct16bInit()
| void * SimdSynetDynamicQuantizedInnerProduct16bInit | ( | size_t | M, |
| size_t | N, | ||
| size_t | K, | ||
| SimdTensorDataType | typeA, | ||
| SimdTensorDataType | typeB, | ||
| SimdTensorDataType | typeC, | ||
| SimdBool | constB, | ||
| SimdBool | bias, | ||
| SimdConvolutionActivationType | activation, | ||
| SimdBool | avoidOverflow | ||
| ) |
Initializes dynamic quantized inner product (matrix multiplication) algorithm for FP32/BF16 input, FP32/BF16/INT8 weight and FP32/BF16 output.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct16b.
Algorithm example:
A[i, k] -> uA[i, k], scaleA[i], zeroA[i]
B[k, j] -> iB[k, j], scaleB[j]
for(i = 0; i < M; ++i)
for(j = 0; j < N; ++j)
{
sum = 0;
for(k = 0; k < K; ++k)
sum += (uA[i, k] - zeroA[i]) * iB[k, j];
val = sum * scaleA[i] * scaleB[j];
C[i, j] = ConvertToTypeC(Activate(val + bias[j], activation, params));
}
- Parameters
-
[in] M - a height of A and C matrices. [in] N - a width of B and C matrices. [in] K - a width of A and height of B matrices. [in] typeA - a type of A matrix. It can be FP32 or BF16. [in] typeB - a type of B matrix. It can be FP32, BF16 or INT8. The last indicates that B is already quantized (works only for constant B). [in] typeC - a type of C matrix. It can be FP32 or BF16. [in] constB - a flag indicating that matrix B is constant and can be set once. [in] bias - a flag to add bias to output matrix C. [in] activation - an activation function type used after inner product. [in] avoidOverflow - a flag to use narrowed ([-64; 63] instead of [-128; 127]) quantization range for B matrix to avoid INT16 overflow on old platforms. Ignored if B is already quantized.
- Returns
- a pointer to dynamic quantized inner product context. On error it returns NULL. It must be released with using of function SimdRelease. This pointer is used in functions SimdSynetDynamicQuantizedInnerProduct16bInternalBufferSize, SimdSynetDynamicQuantizedInnerProduct16bExternalBufferSize, SimdSynetDynamicQuantizedInnerProduct16bInfo, SimdSynetDynamicQuantizedInnerProduct16bSetParams and SimdSynetDynamicQuantizedInnerProduct16bForward.
◆ SimdSynetDynamicQuantizedInnerProduct16bInternalBufferSize()
| size_t SimdSynetDynamicQuantizedInnerProduct16bInternalBufferSize | ( | const void * | context | ) |
Gets the size in bytes of internal storage used by a dynamic quantized inner-product context.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct16b.
- Parameters
-
[in] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct16bInit and released by function SimdRelease.
- Returns
- a number of bytes used by internal buffers.
◆ SimdSynetDynamicQuantizedInnerProduct16bExternalBufferSize()
| size_t SimdSynetDynamicQuantizedInnerProduct16bExternalBufferSize | ( | const void * | context | ) |
Gets number of bytes required for external temporary buffer.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct16b.
- Parameters
-
[in] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct16bInit and released by function SimdRelease.
- Returns
- a number of bytes required for external temporary buffer.
◆ SimdSynetDynamicQuantizedInnerProduct16bInfo()
| const char * SimdSynetDynamicQuantizedInnerProduct16bInfo | ( | const void * | context | ) |
Gets a short description of the selected dynamic quantized inner-product implementation.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct16b.
- Parameters
-
[in] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct16bInit and released by function SimdRelease.
- Returns
- a string with description of internal implementation of dynamic quantized inner product algorithm.
◆ SimdSynetDynamicQuantizedInnerProduct16bSetParams()
| void SimdSynetDynamicQuantizedInnerProduct16bSetParams | ( | void * | context, |
| const uint8_t * | weight, | ||
| const float * | scale, | ||
| const float * | bias, | ||
| const float * | params | ||
| ) |
Sets weights, bias and activation parameters for dynamic quantized inner product.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct16b.
This function must be called before SimdSynetDynamicQuantizedInnerProduct16bForward if initialization parameter constB was SimdTrue.
- Parameters
-
[in,out] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct16bInit and released by function SimdRelease. [in] weight - a pointer to matrix B weights. It may be of FP32 or INT8 type. The size of the array must be equal to K * N. Can be NULL only when B is not constant. [in] scale - a pointer to per-output-channel FP32 scales of B matrix. The size of the array must be equal to N. Can be null if B is not quantized. [in] bias - a pointer to FP32 bias array with N elements. Can be NULL. [in] params - a pointer to FP32 parameters of activation function (see SimdConvolutionActivationType). Can be NULL when activation does not require parameters.
◆ SimdSynetDynamicQuantizedInnerProduct16bForward()
| void SimdSynetDynamicQuantizedInnerProduct16bForward | ( | void * | context, |
| const uint8_t * | A, | ||
| const uint8_t * | B, | ||
| uint8_t * | buf, | ||
| uint8_t * | C | ||
| ) |
Performs dynamic quantized inner-product forward propagation.
- Note
- This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct16b.
- Parameters
-
[in] context - a pointer to dynamic quantized inner product context. It must be created by function SimdSynetDynamicQuantizedInnerProduct16bInit and released by function SimdRelease. [in] A - a pointer to A matrix of FP32 or BF16 type with size M * K. [in] B - a pointer to B matrix of FP32 or BF16 type with size K * N. Can be NULL if B is constant. In that case B must be set by function SimdSynetDynamicQuantizedInnerProduct16bSetParams. [out] buf - a pointer to external temporary buffer. The required size is determined by function SimdSynetDynamicQuantizedInnerProduct16bExternalBufferSize. Can be NULL (it causes usage of internal buffer). [out] C - a pointer to output C matrix of FP32 or BF16 type with size M * N.