qkeras.qtools.quantized_operators.fused_bn_factory
quantized batch normliaztion quantizer implementation.
Classes
determine which quantizer implementation to use. |
- class qkeras.qtools.quantized_operators.fused_bn_factory.FusedBNFactory[source]
Bases:
objectdetermine which quantizer implementation to use.
Create an fused bn instance. The type and bit width of the output_quantizer is deteremined from both the previous layer and batchnorm weight types:
z = bn(y) = bn_inv * x - fused_bias is the output of the previous layer and the following bn layer, with:
- bn_inv = gamma * rsqrt(variance^2+epsilon) is computed from the
bn layer weights with inverse_quantizer datatype
x is the previous layer’s output fused_bias = bn_inv * bias + beta - bn_inv*mean where bias is
the bias term from the previous layer, beta and mean are the bn layer weights.
- make_quantizer(prev_output_quantizer, beta_quantizer, mean_quantizer, inverse_quantizer, prev_bias_quantizer, use_beta, use_bias, qkeras_inverse_quantizer)[source]
Makes a fused_bn quantizer.
- Parameters:
prev_output_quantizer (
IQuantizer) – IQuantizer type. Previous layer output quantizerbeta_quantizer (
IQuantizer) – IQuantizer type. bn layer beta quantizermean_quantizer (
IQuantizer) – IQuantizer type. layer mean quantizerinverse_quantizer (
IQuantizer) – IQuantizer type. bn layer inverse quantizerprev_bias_quantizer (
IQuantizer) – IQuantizer type. conv layer bias quantizeruse_beta (
bool) – Bool. whether enabling beta in batch_normalization layeruse_bias (
bool) – Bool. Whether bias is used in conv layer.qkeras_inverse_quantizer (
BaseQuantizer) – qkeras quantizer type. bn layer inverse quantizer with qkeras quantizer type
- Returns:
None