未验证 提交 cd74b207 编写于 作者: C cc 提交者: GitHub

Add more ops to calculate output scales (#32036)

上级 ed49b418
...@@ -468,7 +468,7 @@ class ImperativeQuantizeOutputs(object): ...@@ -468,7 +468,7 @@ class ImperativeQuantizeOutputs(object):
""" """
Whether the layer needs to calculate output scales. Whether the layer needs to calculate output scales.
""" """
return isinstance(layer, tuple(utils.quant_output_layers_map.values())) \ return isinstance(layer, utils.quant_output_layers) \
or ('quantized' in layer.full_name() and \ or ('quantized' in layer.full_name() and \
'quantized_noweight' not in layer.full_name()) 'quantized_noweight' not in layer.full_name())
......
...@@ -43,28 +43,18 @@ fake_quantize_dequantize_types = [ ...@@ -43,28 +43,18 @@ fake_quantize_dequantize_types = [
"fake_quantize_dequantize_moving_average_abs_max" "fake_quantize_dequantize_moving_average_abs_max"
] ]
quant_output_layers_map = { quant_output_layers = (
'Conv2D': paddle.nn.Conv2D, paddle.nn.Conv2D, paddle.nn.Conv2DTranspose, paddle.nn.Linear,
'Conv2DTranspose': paddle.nn.Conv2DTranspose, paddle.nn.AdaptiveAvgPool2D, paddle.nn.AdaptiveMaxPool2D,
'Linear': paddle.nn.Linear, paddle.nn.AvgPool2D, paddle.nn.MaxPool2D, paddle.nn.BatchNorm,
'AdaptiveAvgPool2D': paddle.nn.AdaptiveAvgPool2D, paddle.nn.BatchNorm2D, paddle.nn.LayerNorm, paddle.nn.SyncBatchNorm,
'AdaptiveMaxPool2D': paddle.nn.AdaptiveMaxPool2D, paddle.nn.ELU, paddle.nn.GELU, paddle.nn.Hardshrink, paddle.nn.Hardsigmoid,
'AvgPool2D': paddle.nn.AvgPool2D, paddle.nn.Hardswish, paddle.nn.Hardtanh, paddle.nn.LeakyReLU,
'MaxPool2D': paddle.nn.MaxPool2D, paddle.nn.LogSigmoid, paddle.nn.LogSoftmax, paddle.nn.Maxout,
'BatchNorm': paddle.nn.BatchNorm, paddle.nn.PReLU, paddle.nn.ReLU, paddle.nn.ReLU6, paddle.nn.SELU,
'BatchNorm2D': paddle.nn.BatchNorm2D, paddle.nn.Sigmoid, paddle.nn.Softmax, paddle.nn.Softplus,
'SyncBatchNorm': paddle.nn.SyncBatchNorm, paddle.nn.Softshrink, paddle.nn.Softsign, paddle.nn.Swish, paddle.nn.Tanh,
'ELU': paddle.nn.ELU, paddle.nn.Tanhshrink, paddle.nn.ThresholdedReLU, paddle.nn.Upsample)
'GELU': paddle.nn.GELU,
'LeakyReLU': paddle.nn.LeakyReLU,
'PReLU': paddle.nn.PReLU,
'ReLU': paddle.nn.ReLU,
'ReLU6': paddle.nn.ReLU6,
'Sigmoid': paddle.nn.Sigmoid,
'Softmax': paddle.nn.Softmax,
'Tanh': paddle.nn.Tanh,
'Swish': paddle.nn.Swish,
}
weight_op_types = [ weight_op_types = [
"conv2d", "depthwise_conv2d", "matmul", "conv2d_transpose", "conv2d", "depthwise_conv2d", "matmul", "conv2d_transpose",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册