Activation functions needed for quantization
These functions are used to accelerate quantization algorithms in Synet Framework. More...
Functions | |
| SIMD_API void | SimdSynetQuantizedHardSigmoid (const uint8_t *src, const float *srcScale, int srcZero, size_t size, const float *scale, const float *shift, uint8_t *dst, const float *dstScale, int dstZero) |
| Performs forward propagation of UINT8 quantized HardSigmoid layer. More... | |
| SIMD_API void | SimdSynetQuantizedHswish (const uint8_t *src, const float *srcScale, int srcZero, size_t size, const float *shift, const float *scale, uint8_t *dst, const float *dstScale, int dstZero) |
| Performs forward propagation of UINT8 quantized Swish layer. More... | |
| SIMD_API void | SimdSynetQuantizedPreluLayerForward (const uint8_t *src, const float *srcScale, int srcZero, size_t channels, size_t spatial, const float *slope, uint8_t *dst, const float *dstScale, int dstZero, SimdTensorFormatType format) |
| Performs forward propagation of UINT8 quantized PReLU layer. More... | |
Detailed Description
These functions are used to accelerate quantization algorithms in Synet Framework.
Function Documentation
◆ SimdSynetQuantizedHardSigmoid()
| void SimdSynetQuantizedHardSigmoid | ( | const uint8_t * | src, |
| const float * | srcScale, | ||
| int | srcZero, | ||
| size_t | size, | ||
| const float * | scale, | ||
| const float * | shift, | ||
| uint8_t * | dst, | ||
| const float * | dstScale, | ||
| int | dstZero | ||
| ) |
Performs forward propagation of UINT8 quantized HardSigmoid layer.
Algorithm's details:
value = (src - srcZero)*srcScale[0]; value = Max(Min(value, shift[0]) + shift[0], 0) * scale[0] * value; dst = RestrictRange(Round(value/dstScale[0]) + dstZero, 0, 255);
- Note
- This function is used in Synet Framework.
- Parameters
-
[in] src - a pointer to UINT8 input tensor. [in] srcScale - a pointer to quantization scale of input tensor. [in] srcZero - a quantization zero parameter of input tensor. [in] size - a size of (input/output) tensors. [in] scale - a pointer to scale parameter. Only scale[0] is used. It is equal to 1/6 in the original paper. [in] shift - a pointer to shift parameter. Only shift[0] is used. It is equal to 1/2 in the original paper. [out] dst - a pointer to UINT8 output tensor. [in] dstScale - a pointer to output quantization scale. [in] dstZero - an output quantization zero.
◆ SimdSynetQuantizedHswish()
| void SimdSynetQuantizedHswish | ( | const uint8_t * | src, |
| const float * | srcScale, | ||
| int | srcZero, | ||
| size_t | size, | ||
| const float * | shift, | ||
| const float * | scale, | ||
| uint8_t * | dst, | ||
| const float * | dstScale, | ||
| int | dstZero | ||
| ) |
Performs forward propagation of UINT8 quantized Swish layer.
Algorithm's details:
value = (src - srcZero)*srcScale[0]; value = Max(0, Min(value * scale[0] + shift[0], 1)); dst = RestrictRange(Round(value/dstScale[0]) + dstZero, 0, 255);
- Note
- This function is used in Synet Framework.
- Parameters
-
[in] src - a pointer to UINT8 input tensor. [in] srcScale - a pointer to quantization scale of input tensor. [in] srcZero - a quantization zero parameter of input tensor. [in] size - a size of (input/output) tensors. [in] shift - a pointer to shift parameter. Only shift[0] is used. It is equal to 3 in the original paper. [in] scale - a pointer to scale parameter. Only scale[0] is used. It is equal to 1/6 in the original paper. [out] dst - a pointer to UINT8 output tensor. [in] dstScale - a pointer to output quantization scale. [in] dstZero - an output quantization zero.
◆ SimdSynetQuantizedPreluLayerForward()
| void SimdSynetQuantizedPreluLayerForward | ( | const uint8_t * | src, |
| const float * | srcScale, | ||
| int | srcZero, | ||
| size_t | channels, | ||
| size_t | spatial, | ||
| const float * | slope, | ||
| uint8_t * | dst, | ||
| const float * | dstScale, | ||
| int | dstZero, | ||
| SimdTensorFormatType | format | ||
| ) |
Performs forward propagation of UINT8 quantized PReLU layer.
Algorithm's details:
value = (src - srcZero)*srcScale[0]; value = value > 0 ? value : slope[c]*value; dst = RestrictRange(Round(value/dstScale[0]) + dstZero, 0, 255);
- Note
- This function is used in Synet Framework.
- Parameters
-
[in] src - a pointer to UINT8 input tensor. [in] srcScale - a pointer to quantization scale of input tensor. [in] srcZero - a quantization zero parameter of input tensor. [in] channels - a number of channels in (input/output) tensors. [in] spatial - a spatial size of (input/output) tensors. [in] slope - a pointer to the 32-bit float array with slope coefficients. The size of the array is equal to channels. [out] dst - a pointer to UINT8 output tensor. [in] dstScale - a pointer to output quantization scale. [in] dstZero - an output quantization zero. [in] format - a format of input and output tensors. It can be SimdTensorFormatNchw or SimdTensorFormatNhwc.