From b8167ed2b19c88cadc73ef02b1c8d0b27f219c94 Mon Sep 17 00:00:00 2001 From: ceci3 Date: Tue, 19 Oct 2021 13:54:58 +0800 Subject: [PATCH] quant support matmul_v2 (#36469) (#36499) * quant support matmul_v2 * fix format --- .../fluid/contrib/slim/quantization/quantization_pass.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py b/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py index e89db1fb1d..dc355fec0d 100644 --- a/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py +++ b/python/paddle/fluid/contrib/slim/quantization/quantization_pass.py @@ -51,6 +51,7 @@ _out_scale_op_list = [ "depthwise_conv2d", "mul", "matmul", + "matmul_v2", "relu", "leaky_relu", "relu6", @@ -91,6 +92,7 @@ _op_real_in_out_name = { "conv2d_transpose": [["Input", "Filter"], ["Output"]], "mul": [["X", "Y"], ["Out"]], "matmul": [["X", "Y"], ["Out"]], + "matmul_v2": [["X", "Y"], ["Out"]], "pool2d": [["X"], ["Out"]], "elementwise_add": [["X", "Y"], ["Out"]], "concat": [["X"], ["Out"]], @@ -139,7 +141,9 @@ _op_real_in_out_name = { _conv_ops = ['conv2d', 'depthwise_conv2d', 'conv2d_transpose'] -_channelwise_quant_axis1_ops = ['conv2d_transpose', 'mul'] +_channelwise_quant_axis1_ops = [ + 'conv2d_transpose', 'mul', 'matmul', 'matmul_v2' +] def _get_op_input_var_names(op): @@ -1785,7 +1789,8 @@ class AddQuantDequantPass(object): "bilinear_interp", "nearest_interp", "trilinear_interp", "slice", "squeeze", "elementwise_sub", "mul", "matmul", "relu", "relu6", "leaky_relu", "tanh", "swish", "scale", "transpose", "transpose2", - "sigmoid", "pad2d", "flatten", "flatten2", "batch_norm", "layer_norm" + "sigmoid", "pad2d", "flatten", "flatten2", "batch_norm", "layer_norm", + "matmul_v2" ] # To be compatible with PaddleSlim, not remove _activation_type for now -- GitLab