MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _IsSkipLayer

Function _IsSkipLayer

tensorflow/contrib/quantize/python/quantize.py:583–606  ·  view source on GitHub ↗

Skip quantizing conv->identity->Batch norm layers. Args: activation_op: Activation op detected by layer matching pattern Returns: skip_layer: boolean, true when conv->identity->batch norm is detected.

(activation_op)

Source from the content-addressed store, hash-verified

581
582
583def _IsSkipLayer(activation_op):
584 """Skip quantizing conv->identity->Batch norm layers.
585
586 Args:
587 activation_op: Activation op detected by layer matching pattern
588
589 Returns:
590 skip_layer: boolean, true when conv->identity->batch norm is detected.
591 """
592
593 # Exclude quantization of conv->identity->BN,
594 # After folding, this part corresponds to estimation of mean and variance
595 # and should not be quantized.
596 skip_layer = False
597 if activation_op.type == 'Identity' and len(activation_op.outputs) == 1:
598 if len(activation_op.outputs[0].consumers()) == 1:
599 consumer = activation_op.outputs[0].consumers()[0]
600 if consumer.type in ['FusedBatchNorm', 'FusedBatchNormV3']:
601 skip_layer = True
602 logging.info(
603 'Skipping quantizing %s, because it is the output of a conv/fc '
604 'followed by a identity, feeding a fused batch norm.',
605 activation_op.name)
606 return skip_layer
607
608
609class _LayerMatch(object):

Callers 1

_FindLayersToQuantizeFunction · 0.85

Calls 2

infoMethod · 0.80
consumersMethod · 0.45

Tested by

no test coverage detected