From 2de2ee29a6b37eaa0d341f586764e5fb2aa96987 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Tue, 30 Aug 2022 16:08:23 +0000 Subject: [PATCH 1/8] remove extra attr of abs in opmaker --- paddle/fluid/operators/abs_op.cc | 9 --------- paddle/phi/api/yaml/api_compat.yaml | 13 +++++++++---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/paddle/fluid/operators/abs_op.cc b/paddle/fluid/operators/abs_op.cc index f0adfb10a9fba..465637f3ed63e 100644 --- a/paddle/fluid/operators/abs_op.cc +++ b/paddle/fluid/operators/abs_op.cc @@ -54,15 +54,6 @@ class AbsOpMaker : public framework::OpProtoAndCheckerMaker { void Make() override { AddInput("X", "(Tensor), The input tensor of abs op."); AddOutput("Out", "(Tensor), The output tensor of abs op."); - AddAttr("use_mkldnn", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr("use_cudnn", - "(bool, default false) Only used in cudnn kernel, need " - "install cudnn") - .SetDefault(false) - .AsExtra(); AddComment(R"DOC( Abs Operator. diff --git a/paddle/phi/api/yaml/api_compat.yaml b/paddle/phi/api/yaml/api_compat.yaml index 84c37cde318cc..3e536420d2155 100644 --- a/paddle/phi/api/yaml/api_compat.yaml +++ b/paddle/phi/api/yaml/api_compat.yaml @@ -1,7 +1,7 @@ -# - api : conv3d_transpose -# backward : conv3d_transpose_grad -# extra : -# attrs : [bool use_cudnn = true, bool use_mkldnn = false, int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB()] +- api : abs + backward : abs_grad + extra : + attrs : [bool use_cudnn = false, bool use_mkldnn = false] - api : atan2 inputs : @@ -46,6 +46,11 @@ float Scale_in_eltwise = 1.0f, 'float[] Scale_weights = {1.0f}', bool force_fp32_output = false, int workspace_size_MB = 512, bool exhaustive_search = false] +- api : conv3d_transpose + backward : conv3d_transpose_grad + extra : + attrs : [bool use_cudnn = true, bool use_mkldnn = false, int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB()] + - api : cross inputs : {x : X, y : Y} From 8aec49f1decd005ed7f1bf3b094f2e25e7a1a670 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Wed, 31 Aug 2022 08:18:22 +0000 Subject: [PATCH 2/8] remove extra attrs of some op in opmaker --- paddle/fluid/operators/addmm_op.cc | 4 - paddle/fluid/operators/affine_grid_op.cc | 5 -- paddle/fluid/operators/angle_op.cc | 9 --- paddle/fluid/operators/batch_norm_op.cc | 8 -- paddle/fluid/operators/clip_op.cc | 10 --- paddle/fluid/operators/concat_op.cc | 17 ---- paddle/fluid/operators/conv_op.cc | 89 +++------------------ paddle/fluid/operators/conv_transpose_op.cc | 59 -------------- paddle/phi/api/yaml/api_compat.yaml | 63 ++++++++++++++- 9 files changed, 73 insertions(+), 191 deletions(-) diff --git a/paddle/fluid/operators/addmm_op.cc b/paddle/fluid/operators/addmm_op.cc index c54e6924c1ae8..8642d572e2d27 100644 --- a/paddle/fluid/operators/addmm_op.cc +++ b/paddle/fluid/operators/addmm_op.cc @@ -72,10 +72,6 @@ class AddMMOpMaker : public framework::OpProtoAndCheckerMaker { AddInput("X", "(Tensor), The first input tensor for mul."); AddInput("Y", "(Tensor), The second input tensor for mul."); AddOutput("Out", "(Tensor), The output tensor of addmm op."); - AddAttr("use_mkldnn", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); AddAttr("Alpha", "coefficient of x*y.").SetDefault(1.0f); AddAttr("Beta", "coefficient of input.").SetDefault(1.0f); AddComment(R"DOC( diff --git a/paddle/fluid/operators/affine_grid_op.cc b/paddle/fluid/operators/affine_grid_op.cc index 6eecb5e6b3e86..a459196b7611d 100644 --- a/paddle/fluid/operators/affine_grid_op.cc +++ b/paddle/fluid/operators/affine_grid_op.cc @@ -158,11 +158,6 @@ class AffineGridOpMaker : public framework::OpProtoAndCheckerMaker { "(Tensor) The shape of target image with format [N, C, H, W].") .AsDispensable(); AddOutput("Output", "(Tensor) Output Tensor with shape [N, H, W, 2]."); - AddAttr( - "use_cudnn", - "(bool, default false) Only used in cudnn kernel, need install cudnn") - .SetDefault(true) - .AsExtra(); AddAttr("align_corners", "(bool, default false) Whether to align the corners of input" "and output.") diff --git a/paddle/fluid/operators/angle_op.cc b/paddle/fluid/operators/angle_op.cc index e787feb7dab94..5c18f4c6fcc7d 100644 --- a/paddle/fluid/operators/angle_op.cc +++ b/paddle/fluid/operators/angle_op.cc @@ -39,15 +39,6 @@ class AngleOpMaker : public framework::OpProtoAndCheckerMaker { void Make() override { AddInput("X", "(Tensor), The input tensor of angle op."); AddOutput("Out", "(Tensor), The output tensor of angle op."); - AddAttr("use_mkldnn", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr("use_cudnn", - "(bool, default false) Only used in cudnn kernel, need " - "install cudnn") - .SetDefault(false) - .AsExtra(); AddComment(R"DOC( Angle Operator. diff --git a/paddle/fluid/operators/batch_norm_op.cc b/paddle/fluid/operators/batch_norm_op.cc index 9ad55c21f1025..a4a3f3cd2b054 100644 --- a/paddle/fluid/operators/batch_norm_op.cc +++ b/paddle/fluid/operators/batch_norm_op.cc @@ -293,14 +293,6 @@ void BatchNormOpMaker::Make() { "NHWC kernel") .AsDispensable() .AsExtra(); - AddAttr("use_mkldnn", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr("fuse_with_relu", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); AddAttr("use_global_stats", "(bool, default false) Whether to use global mean and " "variance. In inference or test mode, set use_global_stats " diff --git a/paddle/fluid/operators/clip_op.cc b/paddle/fluid/operators/clip_op.cc index ee632c77f19dc..7994dacf08794 100644 --- a/paddle/fluid/operators/clip_op.cc +++ b/paddle/fluid/operators/clip_op.cc @@ -64,16 +64,6 @@ class ClipOpMaker : public framework::OpProtoAndCheckerMaker { "input(x)"); AddAttr("min", "float number, the minimum value to clip by."); AddAttr("max", "float number, the maximum value to clip by."); - AddAttr("use_mkldnn", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr( - "mkldnn_data_type", - "(string, default \"float32\"). Data type of mkldnn kernel") - .SetDefault("float32") - .InEnum({"float32", "bfloat16"}) - .AsExtra(); AddComment(R"DOC( Clip Operator. diff --git a/paddle/fluid/operators/concat_op.cc b/paddle/fluid/operators/concat_op.cc index 75dbb9b037944..7c3a8103e1dbb 100644 --- a/paddle/fluid/operators/concat_op.cc +++ b/paddle/fluid/operators/concat_op.cc @@ -81,11 +81,6 @@ class ConcatOpMaker : public framework::OpProtoAndCheckerMaker { void Make() override { AddInput("X", "Input tensors of concat operator.").AsDuplicable(); AddOutput("Out", "Output tensor of concat operator."); - AddAttr( - "use_mkldnn", - "(bool, default false) Indicates if MKL-DNN kernel will be used") - .SetDefault(false) - .AsExtra(); AddAttr("axis", "The axis along which the input tensors will be concatenated." "The axis could also be negative numbers. Negative axis is " @@ -99,18 +94,6 @@ class ConcatOpMaker : public framework::OpProtoAndCheckerMaker { "It has higher priority than Attr(axis). " "The shape of AxisTensor must be [1].") .AsDispensable(); - AddAttr( - "use_quantizer", - "(bool, default false) " - "This parameter is no longer used. Use 'mkldnn_data_type' instead.") - .SetDefault(false) - .AsExtra(); - AddAttr( - "mkldnn_data_type", - "(string, default \"float32\"). Data type of mkldnn kernel") - .SetDefault("float32") - .InEnum({"float32", "int8", "bfloat16"}) - .AsExtra(); AddComment(R"DOC( Concat Operator. diff --git a/paddle/fluid/operators/conv_op.cc b/paddle/fluid/operators/conv_op.cc index ab222f3cb36c1..d85eeff03ecfa 100644 --- a/paddle/fluid/operators/conv_op.cc +++ b/paddle/fluid/operators/conv_op.cc @@ -356,22 +356,6 @@ void Conv2DOpMaker::Make() { "the input will be transformed automatically. ") .SetDefault("NCHW"); // TODO(dzhwinter): need to registered layout transform function - AddAttr("workspace_size_MB", - "Only used in cudnn kernel. Need set use_cudnn to true." - "workspace size for cudnn, in MB, " - "workspace is a section of GPU memory which will be " - "allocated/freed each time the operator runs, larger " - "workspace size can increase performance but also requires " - "better hardware. This size should be chosen carefully.") - .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB()) - .AsExtra(); - AddAttr("exhaustive_search", - "(bool, default false) cuDNN has many algorithm to calculation " - "convolution, whether enable exhaustive search " - "for cuDNN convolution or not, default is False.") - .SetDefault(false) - .AsExtra(); - AddComment(R"DOC( Convolution Operator. @@ -403,6 +387,17 @@ The input(X) size and output(Out) size may be different. Apply(); } +class DepthwiseConv2DOpMaker : public Conv2DOpMaker { + protected: + void Apply() override { + AddAttr( + "use_cudnn", + "(bool, default false) Only used in cudnn kernel, need install cudnn") + .SetDefault(false) + .AsExtra(); + } +}; + void Conv3DOpMaker::Make() { AddAttr("is_test", "(bool, default false) Set to true for inference only, false " @@ -465,47 +460,6 @@ void Conv3DOpMaker::Make() { "dilations(d_dilation, h_dilation, w_dilation) of " "convolution operator.") .SetDefault({1, 1, 1}); - AddAttr( - "use_cudnn", - "(bool, default false) Only used in cudnn kernel, need install cudnn") - .SetDefault(false) - .AsExtra(); - AddAttr("use_mkldnn", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr( - "mkldnn_data_type", - "(string, default \"float32\"). Data type of mkldnn kernel") - .SetDefault("float32") - .InEnum({"float32", "int8", "bfloat16"}) - .AsExtra(); - AddAttr("fuse_relu", "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr("fuse_activation", - "(string, default \"\") Only used in mkldnn kernel") - .SetDefault("") - .AsExtra(); - AddAttr("fuse_alpha", - "(float, default 0.0) Only used in mkldnn kernel") - .SetDefault(0.0f) - .AsExtra(); - AddAttr("fuse_beta", "(float, default 0.0) Only used in mkldnn kernel") - .SetDefault(0.0f) - .AsExtra(); - AddAttr( - "use_addto", - "(bool, default false) If use addto strategy or not, only used in " - "cudnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr("fuse_residual_connection", - "(bool, default false) Only used in mkldnn kernel. Used " - "whenever convolution output is as an input to residual " - "connection.") - .SetDefault(false) - .AsExtra(); AddAttr( "data_format", "(string, default NCDHW) Only used in " @@ -513,25 +467,6 @@ void Conv3DOpMaker::Make() { "Defaults to \"NDHWC\". Specify the data format of the output data, " "the input will be transformed automatically. ") .SetDefault("NCDHW"); - AddAttr("force_fp32_output", - "(bool, default false) Only used in mkldnn INT8 kernel") - .SetDefault(false) - .AsExtra(); - // TODO(dzhwinter): need to registered layout transform function - AddAttr("workspace_size_MB", - "Only used in cudnn kernel. workspace size for cudnn, in MB, " - "workspace is a section of GPU memory which will be " - "allocated/freed each time the operator runs, larger " - "workspace size can increase performance but also requires " - "better hardware. This size should be chosen carefully.") - .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB()) - .AsExtra(); - AddAttr("exhaustive_search", - "(bool, default false) cuDNN has many algorithm to calculation " - "convolution, whether enable exhaustive search " - "for cuDNN convolution or not, default is False.") - .SetDefault(false) - .AsExtra(); AddComment(R"DOC( Convolution3D Operator. @@ -811,7 +746,7 @@ REGISTER_OPERATOR(conv2d_grad_grad, ops::ConvOpDoubleGrad); // depthwise convolution op REGISTER_OPERATOR(depthwise_conv2d, ops::ConvOp, - ops::Conv2DOpMaker, + ops::DepthwiseConv2DOpMaker, ops::ConvOpInferVarType, ops::Conv2DGradMaker, ops::Conv2DGradMaker); diff --git a/paddle/fluid/operators/conv_transpose_op.cc b/paddle/fluid/operators/conv_transpose_op.cc index 3205d5b353887..7426b9a1373c9 100644 --- a/paddle/fluid/operators/conv_transpose_op.cc +++ b/paddle/fluid/operators/conv_transpose_op.cc @@ -146,40 +146,6 @@ void Conv2DTransposeOpMaker::Make() { "(vector default:{0, 0}), the paddings(h_pad, w_pad) of convolution " "transpose operator.") .SetDefault({0, 0}); - AddAttr( - "use_cudnn", - "(bool, default false) Only used in cudnn kernel, need install cudnn") - .SetDefault(false) - .AsExtra(); - AddAttr("use_mkldnn", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr("force_fp32_output", - "(bool, default false) Force BF16 kernel output FP32, only " - "used in MKL-DNN BF16") - .SetDefault(false) - .AsExtra(); - AddAttr( - "mkldnn_data_type", - "(string, default \"float32\"). Data type of mkldnn kernel") - .SetDefault("float32") - .InEnum({"float32", "bfloat16"}) - .AsExtra(); - AddAttr("fuse_relu", "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); - AddAttr("fuse_activation", - "(string, default \"\") Only used in mkldnn kernel") - .SetDefault("") - .AsExtra(); - AddAttr("fuse_alpha", - "(float, default 0.0) Only used in mkldnn kernel") - .SetDefault(0.0f) - .AsExtra(); - AddAttr("fuse_beta", "(float, default 0.0) Only used in mkldnn kernel") - .SetDefault(0.0f) - .AsExtra(); AddAttr( "data_format", "(string, default NCHW) Only used in " @@ -193,14 +159,6 @@ void Conv2DTransposeOpMaker::Make() { "\"SAME\",\"VALID\". Set to \"EXPLICIT\" for explicit padding. " "Set to \"SAME\" or \"VALID\" for algorithm of padding. ") .SetDefault("EXPLICIT"); - AddAttr("workspace_size_MB", - "Used in cudnn kernel only. workspace size for cudnn, in MB, " - "workspace is a section of GPU memory which will be " - "allocated/freed each time the operator runs, larger " - "workspace size can increase performance but also requires " - "better hardward. This size should be carefully set.") - .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB()) - .AsExtra(); AddComment(R"DOC( Convolution2D Transpose Operator. @@ -280,15 +238,6 @@ void Conv3DTransposeOpMaker::Make() { "(int default:1), the groups number of the convolution3d " "transpose operator. ") .SetDefault(1); - AddAttr( - "use_cudnn", - "(bool, default false) Only used in cudnn kernel, need install cudnn") - .SetDefault(false) - .AsExtra(); - AddAttr("use_mkldnn", - "(bool, default false) Only used in mkldnn kernel") - .SetDefault(false) - .AsExtra(); AddAttr( "data_format", "(string, default NCHW) Only used in " @@ -302,14 +251,6 @@ void Conv3DTransposeOpMaker::Make() { "\"SAME\",\"VALID\". Set to \"EXPLICIT\" for explicit padding. " "Set to \"SAME\" or \"VALID\" for algorithm of padding. ") .SetDefault("EXPLICIT"); - AddAttr("workspace_size_MB", - "Used in cudnn kernel only. workspace size for cudnn, in MB, " - "workspace is a section of GPU memory which will be " - "allocated/freed each time the operator runs, larger " - "workspace size can increase performance but also requires " - "better hardward. This size should be carefully set.") - .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB()) - .AsExtra(); AddComment(R"DOC( Convolution3D Transpose Operator. diff --git a/paddle/phi/api/yaml/api_compat.yaml b/paddle/phi/api/yaml/api_compat.yaml index 3e536420d2155..4e6ef76e3cb95 100644 --- a/paddle/phi/api/yaml/api_compat.yaml +++ b/paddle/phi/api/yaml/api_compat.yaml @@ -3,12 +3,32 @@ extra : attrs : [bool use_cudnn = false, bool use_mkldnn = false] +- api : addmm + backward : addmm_grad + extra : + attrs : [bool use_mkldnn = false] + +- api : affine_grid + backward : affine_grid_grad + extra : + attrs : [bool use_cudnn = true] + +- api : angle + backward : angle_grad + extra : + attrs : [bool use_cudnn = false, bool use_mkldnn = false] + - api : atan2 inputs : {x : X1, y : X2} outputs : out : Out +- api : batch_norm + backward : batch_norm_grad + extra : + attrs : [bool use_mkldnn = false, bool fuse_with_relu = false] + - api : bernoulli inputs : x : X @@ -27,6 +47,16 @@ outputs : out : Out +- api : clip + backward : clip_grad + extra : + attrs : [bool use_mkldnn = false, str mkldnn_data_type = "float32"] + +- api : concat + backward : concat_grad + extra : + attrs : [bool use_mkldnn = false, bool use_quantizer = false, str mkldnn_data_type = "float32"] + - api : conv2d backward : conv2d_grad extra : @@ -35,7 +65,7 @@ str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, bool use_addto = false, bool fuse_residual_connection = false, float Scale_in = 1.0f, float Scale_out = 1.0f, float Scale_in_eltwise = 1.0f, 'float[] Scale_weights = {1.0f}', bool force_fp32_output = false, - int workspace_size_MB = 512, bool exhaustive_search = false] + int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB(), bool exhaustive_search = false] - api : conv2d_fusion extra : @@ -46,6 +76,22 @@ float Scale_in_eltwise = 1.0f, 'float[] Scale_weights = {1.0f}', bool force_fp32_output = false, int workspace_size_MB = 512, bool exhaustive_search = false] +- api : conv2d_transpose + backward : conv2d_transpose_grad + extra : + attrs : [bool use_cudnn = true, bool use_mkldnn = false, bool force_fp32_output = false, + str mkldnn_data_type = "float32", bool fuse_relu = false, + str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, + int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB()] + +- api : conv3d + backward : conv3d_grad + extra : + attrs : [bool use_cudnn = false, bool use_mkldnn = false, str mkldnn_data_type = "float32", bool fuse_relu = false, + str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, + bool use_addto = false, bool fuse_residual_connection = false, bool force_fp32_output = false, + int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB(), bool exhaustive_search = false] + - api : conv3d_transpose backward : conv3d_transpose_grad extra : @@ -62,13 +108,21 @@ - api : depthwise_conv2d backward : depthwise_conv2d_grad extra : - attrs : [bool use_cudnn = false, bool fuse_relu_before_depthwise_conv = false, bool use_mkldnn = false, + attrs : [bool fuse_relu_before_depthwise_conv = false, bool use_mkldnn = false, bool use_quantizer = false, str mkldnn_data_type = "float32", bool fuse_relu = false, str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, bool use_addto = false, bool fuse_residual_connection = false, float Scale_in = 1.0f, float Scale_out = 1.0f, float Scale_in_eltwise = 1.0f, 'float[] Scale_weights = {1.0f}', bool force_fp32_output = false, int workspace_size_MB = 512, bool exhaustive_search = false] +- api : depthwise_conv2d_transpose + backward : depthwise_conv2d_transpose_grad + extra : + attrs : [bool use_cudnn = false, bool use_mkldnn = false, bool force_fp32_output = false, + str mkldnn_data_type = "float32", bool fuse_relu = false, + str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, + int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB()] + - api : diag op_name : diag_v2 grad_op_name : diag_v2_grad @@ -137,6 +191,11 @@ outputs : out : Out +- api : sync_batch_norm + backward : sync_batch_norm_grad + extra : + attrs : [bool use_mkldnn = false, bool fuse_with_relu = false] + - api : trace inputs : x : Input From ffbb0573c442ccb4995eb6940f6416cd7e4a3e57 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Wed, 31 Aug 2022 12:10:00 +0000 Subject: [PATCH 3/8] remove is_test of conv --- paddle/fluid/operators/conv_op.cc | 10 ---------- paddle/fluid/operators/conv_transpose_op.cc | 5 ----- paddle/phi/api/yaml/api_compat.yaml | 16 ++++++++-------- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/paddle/fluid/operators/conv_op.cc b/paddle/fluid/operators/conv_op.cc index d85eeff03ecfa..d9c1332191ac7 100644 --- a/paddle/fluid/operators/conv_op.cc +++ b/paddle/fluid/operators/conv_op.cc @@ -285,11 +285,6 @@ framework::OpKernelType ConvOp::GetKernelTypeForVar( } void Conv2DOpMaker::Make() { - AddAttr("is_test", - "(bool, default false) Set to true for inference only, false " - "for training. Some layers may run faster when this is true.") - .SetDefault(false) - .AsExtra(); AddInput("Input", "(Tensor) The input tensor of convolution operator. " "The format of input tensor is NCHW or NHWC, where N is batch size, " @@ -399,11 +394,6 @@ class DepthwiseConv2DOpMaker : public Conv2DOpMaker { }; void Conv3DOpMaker::Make() { - AddAttr("is_test", - "(bool, default false) Set to true for inference only, false " - "for training. Some layers may run faster when this is true.") - .SetDefault(false) - .AsExtra(); AddInput( "Input", "(Tensor) The input tensor of convolution operator. " diff --git a/paddle/fluid/operators/conv_transpose_op.cc b/paddle/fluid/operators/conv_transpose_op.cc index 7426b9a1373c9..56875c2d433e1 100644 --- a/paddle/fluid/operators/conv_transpose_op.cc +++ b/paddle/fluid/operators/conv_transpose_op.cc @@ -91,11 +91,6 @@ framework::OpKernelType ConvTransposeOp::GetKernelTypeForVar( } void Conv2DTransposeOpMaker::Make() { - AddAttr("is_test", - "(bool, default false) Set to true for inference only, false " - "for training. Some layers may run faster when this is true.") - .SetDefault(false) - .AsExtra(); AddInput("Input", "(Tensor) The input tensor of convolution transpose operator. " "The format of input tensor is NCHW or NHWC. Where N is batch size, " diff --git a/paddle/phi/api/yaml/api_compat.yaml b/paddle/phi/api/yaml/api_compat.yaml index 4e6ef76e3cb95..2f7b379c27e89 100644 --- a/paddle/phi/api/yaml/api_compat.yaml +++ b/paddle/phi/api/yaml/api_compat.yaml @@ -60,7 +60,7 @@ - api : conv2d backward : conv2d_grad extra : - attrs : [bool use_cudnn = false, bool fuse_relu_before_depthwise_conv = false, bool use_mkldnn = false, + attrs : [bool is_test = false, bool use_cudnn = false, bool fuse_relu_before_depthwise_conv = false, bool use_mkldnn = false, bool use_quantizer = false, str mkldnn_data_type = "float32", bool fuse_relu = false, str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, bool use_addto = false, bool fuse_residual_connection = false, float Scale_in = 1.0f, float Scale_out = 1.0f, @@ -69,17 +69,17 @@ - api : conv2d_fusion extra : - attrs : [bool use_cudnn = false, bool fuse_relu_before_depthwise_conv = false, bool use_mkldnn = false, + attrs : [bool is_test = false, bool use_cudnn = false, bool fuse_relu_before_depthwise_conv = false, bool use_mkldnn = false, bool use_quantizer = false, str mkldnn_data_type = "float32", bool fuse_relu = false, str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, bool use_addto = false, bool fuse_residual_connection = false, float Scale_in = 1.0f, float Scale_out = 1.0f, float Scale_in_eltwise = 1.0f, 'float[] Scale_weights = {1.0f}', bool force_fp32_output = false, - int workspace_size_MB = 512, bool exhaustive_search = false] + int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB(), bool exhaustive_search = false] - api : conv2d_transpose backward : conv2d_transpose_grad extra : - attrs : [bool use_cudnn = true, bool use_mkldnn = false, bool force_fp32_output = false, + attrs : [bool is_test = false, bool use_cudnn = true, bool use_mkldnn = false, bool force_fp32_output = false, str mkldnn_data_type = "float32", bool fuse_relu = false, str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB()] @@ -87,7 +87,7 @@ - api : conv3d backward : conv3d_grad extra : - attrs : [bool use_cudnn = false, bool use_mkldnn = false, str mkldnn_data_type = "float32", bool fuse_relu = false, + attrs : [bool is_test = false, bool use_cudnn = false, bool use_mkldnn = false, str mkldnn_data_type = "float32", bool fuse_relu = false, str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, bool use_addto = false, bool fuse_residual_connection = false, bool force_fp32_output = false, int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB(), bool exhaustive_search = false] @@ -108,17 +108,17 @@ - api : depthwise_conv2d backward : depthwise_conv2d_grad extra : - attrs : [bool fuse_relu_before_depthwise_conv = false, bool use_mkldnn = false, + attrs : [bool is_test = false, bool fuse_relu_before_depthwise_conv = false, bool use_mkldnn = false, bool use_quantizer = false, str mkldnn_data_type = "float32", bool fuse_relu = false, str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, bool use_addto = false, bool fuse_residual_connection = false, float Scale_in = 1.0f, float Scale_out = 1.0f, float Scale_in_eltwise = 1.0f, 'float[] Scale_weights = {1.0f}', bool force_fp32_output = false, - int workspace_size_MB = 512, bool exhaustive_search = false] + int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB(), bool exhaustive_search = false] - api : depthwise_conv2d_transpose backward : depthwise_conv2d_transpose_grad extra : - attrs : [bool use_cudnn = false, bool use_mkldnn = false, bool force_fp32_output = false, + attrs : [bool is_test = false, bool use_cudnn = false, bool use_mkldnn = false, bool force_fp32_output = false, str mkldnn_data_type = "float32", bool fuse_relu = false, str fuse_activation = "", float fuse_alpha = 0.0f, float fuse_beta = 0.0f, int workspace_size_MB = platform::GetDefaultConvWorkspaceSizeLimitMB()] From 7c697e4bbd0c604612e33b82319efbd1fdc9ba16 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Wed, 31 Aug 2022 16:04:10 +0000 Subject: [PATCH 4/8] fix attr getting of interpretercore --- paddle/fluid/framework/new_executor/new_executor_defs.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paddle/fluid/framework/new_executor/new_executor_defs.cc b/paddle/fluid/framework/new_executor/new_executor_defs.cc index 6492538c6084d..8ee7065368c21 100644 --- a/paddle/fluid/framework/new_executor/new_executor_defs.cc +++ b/paddle/fluid/framework/new_executor/new_executor_defs.cc @@ -117,7 +117,7 @@ bool InterpretercoreInferShapeContext::HasOutputs(const std::string& name, } AttrReader InterpretercoreInferShapeContext::Attrs() const { - return AttrReader(op_.Attrs()); + return AttrReader(op_.Attrs(), op_.RuntimeAttrs()); } std::vector InterpretercoreInferShapeContext::Inputs( From e1971d1ce38104d0afe801f57623e7956a4987d6 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Wed, 31 Aug 2022 17:30:48 +0000 Subject: [PATCH 5/8] fix inplace_abn --- paddle/phi/api/yaml/api_compat.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/paddle/phi/api/yaml/api_compat.yaml b/paddle/phi/api/yaml/api_compat.yaml index 92e179a27eda9..912d63a776b43 100644 --- a/paddle/phi/api/yaml/api_compat.yaml +++ b/paddle/phi/api/yaml/api_compat.yaml @@ -167,6 +167,11 @@ outputs : out : Out +- api : inplace_abn + backward : inplace_abn_grad + extra : + attrs : [bool use_mkldnn = false, bool fuse_with_relu = false] + - api : lgamma inputs : x : X From 6b4c5f313b618fe9f997a74955f19c7b6cf61e71 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Thu, 1 Sep 2022 06:39:55 +0000 Subject: [PATCH 6/8] fix bug --- paddle/fluid/framework/operator.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index 04d51872852a7..00a4993500449 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -767,7 +767,9 @@ class RuntimeInferShapeContext : public InferShapeContext { } } - AttrReader Attrs() const override { return AttrReader(op_.Attrs()); } + AttrReader Attrs() const override { + return AttrReader(op_.Attrs(), op_.RuntimeAttrs()); + } std::vector Inputs(const std::string& name) const override { return op_.Inputs(name); From 7b3043513b4d634a056d9d0d8cb06e5ff5f6cf36 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Thu, 1 Sep 2022 09:37:11 +0000 Subject: [PATCH 7/8] fix bug of create_op --- paddle/fluid/framework/op_registry.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/op_registry.cc b/paddle/fluid/framework/op_registry.cc index a5ce5b704921b..69f85bd97cc6f 100644 --- a/paddle/fluid/framework/op_registry.cc +++ b/paddle/fluid/framework/op_registry.cc @@ -65,7 +65,15 @@ std::unique_ptr OpRegistry::CreateOp( op_base = std::unique_ptr( info.Creator()(type, inputs, outputs, attrs)); } - op_base->SetRuntimeAttributeMap(runtime_attrs); + const auto& extra_attr_checkers = + operators::ExtraInfoUtils::Instance().GetExtraAttrsChecker(type); + if(!extra_attr_checkers.empty()) { + auto op_runtime_attr_map = runtime_attrs; + for (const auto& checker : extra_attr_checkers) { + checker(&op_runtime_attr_map, false); + } + op_base->SetRuntimeAttributeMap(op_runtime_attr_map); + } return op_base; } From 9be5d9133affb45695247a8eaf3b97aa68e47415 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Thu, 1 Sep 2022 09:46:39 +0000 Subject: [PATCH 8/8] refine code format --- paddle/fluid/framework/op_registry.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/framework/op_registry.cc b/paddle/fluid/framework/op_registry.cc index 69f85bd97cc6f..a60563620ad65 100644 --- a/paddle/fluid/framework/op_registry.cc +++ b/paddle/fluid/framework/op_registry.cc @@ -66,8 +66,8 @@ std::unique_ptr OpRegistry::CreateOp( info.Creator()(type, inputs, outputs, attrs)); } const auto& extra_attr_checkers = - operators::ExtraInfoUtils::Instance().GetExtraAttrsChecker(type); - if(!extra_attr_checkers.empty()) { + operators::ExtraInfoUtils::Instance().GetExtraAttrsChecker(type); + if (!extra_attr_checkers.empty()) { auto op_runtime_attr_map = runtime_attrs; for (const auto& checker : extra_attr_checkers) { checker(&op_runtime_attr_map, false);