Skip to content

Commit 82b880d

Browse files
committed
+add API of SynetDynamicQuantizedInnerProduct.
1 parent e2d1f0c commit 82b880d

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

‎prj/txt/DoxygenGroups.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,11 @@
500500
\short A framework to accelerate QuantizedInnerProductLayer in <a href="http://github.com/ermig1979/Synet">Synet Framework</a>.
501501
*/
502502

503+
/*! @ingroup synet_quantized
504+
@defgroup synet_dynamic_quantized_inner_product DynamicQuantizedInnerProductLayer functions
505+
\short A framework to accelerate DynamicQuantizedInnerProductLayer in <a href="http://github.com/ermig1979/Synet">Synet Framework</a>.
506+
*/
507+
503508
/*! @ingroup synet_quantized
504509
@defgroup synet_quantized_activation Activation functions needed for quantization
505510
\short These functions are used to accelerate quantization algorithms in <a href="http://github.com/ermig1979/Synet">Synet Framework</a>.

‎src/Simd/SimdLib.h‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7003,6 +7003,96 @@ extern "C"
70037003
*/
70047004
SIMD_API void SimdSynetDequantizeLinear(const uint8_t* src, size_t size, int32_t bias, const float* norm, float* dst);
70057005

7006+
/*! @ingroup synet_dynamic_quantized_inner_product
7007+
7008+
\fn void* SimdSynetDynamicQuantizedInnerProductInit(size_t M, size_t N, size_t K, SimdBool bias, SimdConvolutionActivationType activation);
7009+
7010+
\short Initializes dynamic quantized inner product (matrix multiplication) algorithm for FP32 input, INT8 weight and FP32 output.
7011+
7012+
\note This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct.
7013+
7014+
\param [in] M - a height of A and height of C matrices.
7015+
\param [in] N - a width of B and width of C matrices.
7016+
\param [in] K - a width of A and height of B matrices.
7017+
\param [in] bias - a flag to add bias to output matrix C.
7018+
\param [in] activation - an activation function type applied after the rest operations.
7019+
\return a pointer to quantized inner product context. On error it returns NULL. It must be released with using of function ::SimdRelease.
7020+
This pointer is used in functions ::SimdSynetDynamicQuantizedInnerProductInternalBufferSize, ::SimdSynetDynamicQuantizedInnerProductExternalBufferSize,
7021+
::SimdSynetDynamicQuantizedInnerProductInfo, ::SimdSynetDynamicQuantizedInnerProductSetParams and ::SimdSynetDynamicQuantizedInnerProductForward.
7022+
*/
7023+
SIMD_API void* SimdSynetDynamicQuantizedInnerProductInit(size_t M, size_t N, size_t K, SimdBool bias, SimdConvolutionActivationType activation);
7024+
7025+
/*! @ingroup synet_dynamic_quantized_inner_product
7026+
7027+
\fn size_t SimdSynetDynamicQuantizedInnerProductInternalBufferSize(const void * context);
7028+
7029+
\short Gets size in bytes of internal buffers allocated by dynamic quantized inner product context.
7030+
7031+
\note This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct.
7032+
7033+
\param [in] context - a pointer to dynamic quantized inner product context. It must be created by function ::SimdSynetDynamicQuantizedInnerProductInit and released by function ::SimdRelease.
7034+
\return size in bytes of internal buffers used inside the algorithm.
7035+
*/
7036+
SIMD_API size_t SimdSynetDynamicQuantizedInnerProductInternalBufferSize(const void* context);
7037+
7038+
/*! @ingroup synet_dynamic_quantized_inner_product
7039+
7040+
\fn size_t SimdSynetDynamicQuantizedInnerProductExternalBufferSize(const void * context);
7041+
7042+
\short Gets size in bytes of external temporary buffer required for dynamic quantized inner product.
7043+
7044+
\note This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct.
7045+
7046+
\param [in] context - a pointer to dynamic quantized inner product context. It must be created by function ::SimdSynetDynamicQuantizedInnerProductInit and released by function ::SimdRelease.
7047+
\return size in bytes of external temporary buffer required by ::SimdSynetDynamicQuantizedInnerProductForward.
7048+
*/
7049+
SIMD_API size_t SimdSynetDynamicQuantizedInnerProductExternalBufferSize(const void* context);
7050+
7051+
/*! @ingroup synet_dynamic_quantized_inner_product
7052+
7053+
\fn const char* SimdSynetDynamicQuantizedInnerProductInfo(const void * context);
7054+
7055+
\short Gets description of selected dynamic quantized inner product implementation.
7056+
7057+
\note This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct.
7058+
7059+
\param [in] context - a pointer to dynamic quantized inner product context. It must be created by function ::SimdSynetDynamicQuantizedInnerProductInit and released by function ::SimdRelease.
7060+
\return string with description of selected implementation (extension and algorithm name).
7061+
*/
7062+
SIMD_API const char* SimdSynetDynamicQuantizedInnerProductInfo(const void* context);
7063+
7064+
/*! @ingroup synet_dynamic_quantized_inner_product
7065+
7066+
\fn void SimdSynetDynamicQuantizedInnerProductSetParams(void* context, const int8_t* weight, const float* scale, const float* bias, const float* params);
7067+
7068+
\short Sets constant matrix B, bias and dynamic quantization parameters for quantized inner product.
7069+
7070+
\note This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct.
7071+
7072+
\param [in, out] context - a pointer to dynamic quantized inner product context. It must be created by function ::SimdSynetDynamicQuantizedInnerProductInit and released by function ::SimdRelease.
7073+
\param [in] weight - a pointer to constant INT8 B matrix. The size of the array must be equal to K * N;
7074+
\param [in] scale - a pointer to per-output-channel FP32 scales of B matrix. The size of the array must be equal to N.
7075+
\param [in] bias - a pointer to per-output-channel FP32 bias. Can be NULL. Otherwise the size of the array must be equal to N.
7076+
\param [in] params - a pointer to FP32 activation parameters (see ::SimdConvolutionActivationType). Can be NULL.
7077+
*/
7078+
SIMD_API void SimdSynetDynamicQuantizedInnerProductSetParams(void* context, const int8_t* weight, const float* scale, const float* bias, const float* params);
7079+
7080+
/*! @ingroup synet_dynamic_quantized_inner_product
7081+
7082+
\fn void SimdSynetDynamicQuantizedInnerProductForward(void* context, const uint8_t* A, const uint8_t* B, uint8_t* buf, uint8_t* C);
7083+
7084+
\short Performs forward propagation of dynamic quantized inner product.
7085+
7086+
\note This function has a C++ wrapper: Simd::SynetDynamicQuantizedInnerProduct.
7087+
7088+
\param [in] context - a pointer to dynamic quantized inner product context. It must be created by function ::SimdSynetDynamicQuantizedInnerProductInit and released by function ::SimdRelease.
7089+
\param [in] A - a pointer to FP32 A matrix with size M*K.
7090+
\param [out] buf - a pointer to external buffer. The size of the external temporary buffer is determined by function ::SimdSynetDynamicQuantizedInnerProductExternalBufferSize.
7091+
Can be NULL (it causes usage of internal buffer).
7092+
\param [out] C - a pointer to FP32 C matrix with size M*N.
7093+
*/
7094+
SIMD_API void SimdSynetDynamicQuantizedInnerProductForward(void* context, const float* A, uint8_t* buf, float* C);
7095+
70067096
/*! @ingroup synet_other
70077097

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

0 commit comments

Comments
 (0)