diff --git a/paddle/fluid/operators/fake_quantize_op.cc b/paddle/fluid/operators/fake_quantize_op.cc index cb8263714a5e47b1397a62b78588f2d9b9d9aaae..bf1f0103f768bbf94ef892ff7dbacdfac45d20b7 100644 --- a/paddle/fluid/operators/fake_quantize_op.cc +++ b/paddle/fluid/operators/fake_quantize_op.cc @@ -432,24 +432,6 @@ class FakeQuantOrWithDequantAbsMaxOpMaker "the received is %d", bit_length)); }); - AddAttr( - "round_type", - "(int, default 1) The round type of fp32 to int." - "0: rounding to nearest ties to even. Eg: round(1.5)=2, round(2.5)=2" - "1: rounding to nearest ties away from zero. Eg: round(1.5)=2, " - "round(2.5)=3") - .SetDefault(1) - .AddCustomChecker([](const int &round_type) { - PADDLE_ENFORCE_EQ( - round_type == 0 || round_type == 1, - true, - platform::errors::InvalidArgument( - "'round_type' should be 0 or 1, 0 rounding to " - "nearest ties to even and 1 is rounding to nearest " - "ties away from zero.but the received is %d", - round_type)); - }) - .AsExtra(); AddComment(R"DOC( This is a Base Op which supports FakeQuantAbsMaxOpMaker and FakeQuantDequantAbsMaxOpMaker. FakeQuantAbsMaxOp operator is used in the dynamic quantization. @@ -529,24 +511,6 @@ class FakeChannelWiseQuantizeAbsMaxOpMaker "the received is %d", bit_length)); }); - AddAttr( - "round_type", - "(int, default 1) The round type of fp32 to int." - "0: rounding to nearest ties to even. Eg: round(1.5)=2, round(2.5)=2" - "1: rounding to nearest ties away from zero. Eg: round(1.5)=2, " - "round(2.5)=3") - .SetDefault(1) - .AddCustomChecker([](const int &round_type) { - PADDLE_ENFORCE_EQ( - round_type == 0 || round_type == 1, - true, - platform::errors::InvalidArgument( - "'round_type' should be 0 or 1, 0 rounding to " - "nearest ties to even and 1 is rounding to nearest " - "ties away from zero.but the received is %d", - round_type)); - }) - .AsExtra(); AddAttr("is_test", "(bool, default false) Set to true for inference only, false " "for training. Some layers may run faster when this is true.") @@ -628,24 +592,6 @@ class FakeChannelWiseQuantizeDequantizeAbsMaxOpMaker "the received is %d", bit_length)); }); - AddAttr( - "round_type", - "(int, default 1) The round type of fp32 to int." - "0: rounding to nearest ties to even. Eg: round(1.5)=2, round(2.5)=2" - "1: rounding to nearest ties away from zero. Eg: round(1.5)=2, " - "round(2.5)=3") - .SetDefault(1) - .AddCustomChecker([](const int &round_type) { - PADDLE_ENFORCE_EQ( - round_type == 0 || round_type == 1, - true, - platform::errors::InvalidArgument( - "'round_type' should be 0 or 1, 0 rounding to " - "nearest ties to even and 1 is rounding to nearest " - "ties away from zero.but the received is %d", - round_type)); - }) - .AsExtra(); AddComment(R"DOC( The scale of FakeChannelWiseQuantize operator is a vector. In detail, each channel of the input X has a scale value. @@ -715,24 +661,6 @@ class FakeQuantizeRangeAbsMaxOpMaker "the received is %d", bit_length)); }); - AddAttr( - "round_type", - "(int, default 1) The round type of fp32 to int." - "0: rounding to nearest ties to even. Eg: round(1.5)=2, round(2.5)=2" - "1: rounding to nearest ties away from zero. Eg: round(1.5)=2, " - "round(2.5)=3") - .SetDefault(1) - .AddCustomChecker([](const int &round_type) { - PADDLE_ENFORCE_EQ( - round_type == 0 || round_type == 1, - true, - platform::errors::InvalidArgument( - "'round_type' should be 0 or 1, 0 rounding to " - "nearest ties to even and 1 is rounding to nearest " - "ties away from zero.but the received is %d", - round_type)); - }) - .AsExtra(); AddAttr("is_test", "(bool, default false) Set to true for inference only, false " "for training. Some layers may run faster when this is true.") @@ -815,24 +743,6 @@ class FakeQuantOrWithDequantMovingAverageAbsMaxOpMaker "the received is %d", bit_length)); }); - AddAttr( - "round_type", - "(int, default 1) The round type of fp32 to int." - "0: rounding to nearest ties to even. Eg: round(1.5)=2, round(2.5)=2" - "1: rounding to nearest ties away from zero. Eg: round(1.5)=2, " - "round(2.5)=3") - .SetDefault(1) - .AddCustomChecker([](const int &round_type) { - PADDLE_ENFORCE_EQ( - round_type == 0 || round_type == 1, - true, - platform::errors::InvalidArgument( - "'round_type' should be 0 or 1, 0 rounding to " - "nearest ties to even and 1 is rounding to nearest " - "ties away from zero.but the received is %d", - round_type)); - }) - .AsExtra(); AddAttr("is_test", "(bool, default false) Set to true for inference only, false " "for training. Some layers may run faster when this is true.") diff --git a/paddle/fluid/operators/quantize_linear_op.cc b/paddle/fluid/operators/quantize_linear_op.cc index 7012da3aeda94a98daea82138fdf7185a8ce2378..d4cd685575eecc31843b9d6005a83227b576369f 100644 --- a/paddle/fluid/operators/quantize_linear_op.cc +++ b/paddle/fluid/operators/quantize_linear_op.cc @@ -134,10 +134,6 @@ class QuantizeLinearOpMaker : public framework::OpProtoAndCheckerMaker { AddOutput("OutScale", "(Tensor) Current scale") .AsDispensable() .AsExtra(); // only qat use - AddAttr("moving_rate", - "(float, default 0.9) moving rate.") // only qat use - .SetDefault(0.9) - .AsExtra(); AddAttr("quant_axis", "(int, default 0) The axis for quantization. " "For conv2d, depthwise_conv2d, conv2d_transpose " diff --git a/paddle/phi/api/yaml/op_compat.yaml b/paddle/phi/api/yaml/op_compat.yaml index 2ccbdc1c383e77511638675f2b97f748924e42d9..7d5311b0799c0cac7f65b97407fca2cb4ef50a5c 100644 --- a/paddle/phi/api/yaml/op_compat.yaml +++ b/paddle/phi/api/yaml/op_compat.yaml @@ -179,6 +179,10 @@ str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB()] +- op : dequantize_linear + extra : + attrs : [float moving_rate = 0.9] + - op : diag (diag_v2) backward : diag_grad (diag_v2_grad) inputs : @@ -271,6 +275,34 @@ extra : attrs : [bool use_mkldnn = false, bool use_cudnn = false] +- op : fake_channel_wise_quantize_abs_max + extra : + attrs : [int round_type = 1] + +- op : fake_channel_wise_quantize_dequantize_abs_max + extra : + attrs : [int round_type = 1] + +- op : fake_quantize_abs_max + extra : + attrs : [int round_type = 1] + +- op : fake_quantize_dequantize_abs_max + extra : + attrs : [int round_type = 1] + +- op : fake_quantize_dequantize_moving_average_abs_max + extra : + attrs : [int round_type = 1] + +- op : fake_quantize_moving_average_abs_max + extra : + attrs : [int round_type = 1] + +- op : fake_quantize_range_abs_max + extra : + attrs : [int round_type = 1] + - op : fft_c2c inputs: {x: X} outputs: {out: Out} @@ -495,6 +527,10 @@ extra : attrs : [bool use_mkldnn = false, str mkldnn_data_type = "float32", bool is_test = false] +- op : quantize_linear + extra : + attrs : [float moving_rate = 0.9] + - op : reciprocal backward : reciprocal_grad extra :