From 7667e59bf70f3e4e22c301feb12b20474bf94ebf Mon Sep 17 00:00:00 2001 From: cc <52520497+juncaipeng@users.noreply.github.com> Date: Mon, 28 Dec 2020 14:06:23 +0800 Subject: [PATCH] add op version for fake_quant and fake_dequant ops, test=op_version (#29923) * add op version for fake_quant and fake_dequant ops, test=op_version, test=develop --- paddle/fluid/operators/fake_dequantize_op.cc | 8 ++++++++ paddle/fluid/operators/fake_quantize_op.cc | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/paddle/fluid/operators/fake_dequantize_op.cc b/paddle/fluid/operators/fake_dequantize_op.cc index 9b0328b094..b70fe78e1a 100644 --- a/paddle/fluid/operators/fake_dequantize_op.cc +++ b/paddle/fluid/operators/fake_dequantize_op.cc @@ -15,6 +15,7 @@ limitations under the License. */ #include "paddle/fluid/operators/fake_dequantize_op.h" #include #include +#include "paddle/fluid/framework/op_version_registry.h" namespace paddle { namespace operators { @@ -238,3 +239,10 @@ REGISTER_OPERATOR( REGISTER_OP_CPU_KERNEL(fake_channel_wise_dequantize_max_abs, ops::FakeChannelWiseDequantizeMaxAbsKernel, ops::FakeChannelWiseDequantizeMaxAbsKernel); + +REGISTER_OP_VERSION(fake_channel_wise_dequantize_max_abs) + .AddCheckpoint( + R"ROC(add new attributes [quant_axis] for applying per-channel " + "dequantization to conv2d_tranpose and mul ops.)ROC", + paddle::framework::compatible::OpVersionDesc().NewAttr( + "quant_axis", "The axis for dequantization.", 0)); diff --git a/paddle/fluid/operators/fake_quantize_op.cc b/paddle/fluid/operators/fake_quantize_op.cc index 04fa8db9a5..df4debb620 100644 --- a/paddle/fluid/operators/fake_quantize_op.cc +++ b/paddle/fluid/operators/fake_quantize_op.cc @@ -16,6 +16,7 @@ limitations under the License. */ #include #include #include "paddle/fluid/framework/eigen.h" +#include "paddle/fluid/framework/op_version_registry.h" #include "paddle/fluid/operators/clip_op.h" #include "paddle/fluid/platform/transform.h" @@ -805,3 +806,10 @@ REGISTER_OPERATOR(fake_channel_wise_quantize_dequantize_abs_max, REGISTER_OP_CPU_KERNEL( fake_channel_wise_quantize_dequantize_abs_max, ops::FakeChannelWiseQuantizeDequantizeAbsMaxKernel); + +REGISTER_OP_VERSION(fake_channel_wise_quantize_abs_max) + .AddCheckpoint( + R"ROC(add new attributes [quant_axis] for applying per-channel " + "quantization to conv2d_tranpose and mul ops.)ROC", + paddle::framework::compatible::OpVersionDesc().NewAttr( + "quant_axis", "The axis for quantization.", 0)); -- GitLab