From 80310541c71d5da7b0c8ad6c996166e36892ea28 Mon Sep 17 00:00:00 2001 From: Jiabin Yang <360788950@qq.com> Date: Fri, 3 Feb 2023 10:29:23 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90Prim=E3=80=91optimize=20log=20(#50160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * optimize log * fix type error * fix type error2 --- paddle/fluid/operators/elementwise/elementwise_add_op.cc | 2 +- paddle/fluid/operators/elementwise/elementwise_div_op.cc | 2 +- paddle/fluid/operators/elementwise/elementwise_mul_op.cc | 2 +- paddle/fluid/operators/elementwise/elementwise_sub_op.cc | 2 +- paddle/fluid/operators/expand_v2_op.cc | 2 +- paddle/fluid/operators/generator/templates/operator_utils.c.j2 | 2 +- paddle/fluid/operators/reduce_ops/reduce_sum_op.cc | 2 +- paddle/fluid/prim/utils/static/composite_grad_desc_maker.h | 3 +++ 8 files changed, 10 insertions(+), 7 deletions(-) diff --git a/paddle/fluid/operators/elementwise/elementwise_add_op.cc b/paddle/fluid/operators/elementwise/elementwise_add_op.cc index 26fcd53621a..c122a07c9b1 100644 --- a/paddle/fluid/operators/elementwise/elementwise_add_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_add_op.cc @@ -67,7 +67,7 @@ class ElementwiseAddCompositeGradOpMaker auto dy_ptr = this->GetOutputPtr(&dy); std::string dy_name = this->GetOutputName(dy); int axis = static_cast(this->Attr("axis")); - VLOG(3) << "Runing add_grad composite func"; + VLOG(6) << "Runing add_grad composite func"; prim::add_grad(x, y, out_grad, axis, dx_ptr, dy_ptr); this->RecoverOutputName(dx, dx_name); this->RecoverOutputName(dy, dy_name); diff --git a/paddle/fluid/operators/elementwise/elementwise_div_op.cc b/paddle/fluid/operators/elementwise/elementwise_div_op.cc index 7d96c310658..97941aa82f3 100644 --- a/paddle/fluid/operators/elementwise/elementwise_div_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_div_op.cc @@ -84,7 +84,7 @@ class ElementwiseDivCompositeGradOpMaker auto dy_ptr = this->GetOutputPtr(&dy); std::string dy_name = this->GetOutputName(dy); int axis = static_cast(this->Attr("axis")); - VLOG(3) << "Runing div_grad composite func"; + VLOG(6) << "Runing div_grad composite func"; prim::divide_grad( x, y, out, out_grad, axis, dx_ptr, dy_ptr); this->RecoverOutputName(dx, dx_name); diff --git a/paddle/fluid/operators/elementwise/elementwise_mul_op.cc b/paddle/fluid/operators/elementwise/elementwise_mul_op.cc index 61467be4c9b..9821cc22612 100644 --- a/paddle/fluid/operators/elementwise/elementwise_mul_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_mul_op.cc @@ -88,7 +88,7 @@ class ElementwiseMulCompositeGradOpMaker static_cast(this->Attr("axis")), x_grad_p, y_grad_p); - VLOG(3) << "Runing mul_grad composite func"; + VLOG(6) << "Runing mul_grad composite func"; this->RecoverOutputName(x_grad, x_grad_name); this->RecoverOutputName(y_grad, y_grad_name); } diff --git a/paddle/fluid/operators/elementwise/elementwise_sub_op.cc b/paddle/fluid/operators/elementwise/elementwise_sub_op.cc index d19f557bfe3..a7244062632 100644 --- a/paddle/fluid/operators/elementwise/elementwise_sub_op.cc +++ b/paddle/fluid/operators/elementwise/elementwise_sub_op.cc @@ -70,7 +70,7 @@ class ElementwiseSubCompositeGradOpMaker auto dy_ptr = this->GetOutputPtr(&dy); std::string dy_name = this->GetOutputName(dy); int axis = static_cast(this->Attr("axis")); - VLOG(3) << "Runing sub_grad composite func"; + VLOG(6) << "Runing sub_grad composite func"; prim::subtract_grad(x, y, out_grad, axis, dx_ptr, dy_ptr); this->RecoverOutputName(dx, dx_name); this->RecoverOutputName(dy, dy_name); diff --git a/paddle/fluid/operators/expand_v2_op.cc b/paddle/fluid/operators/expand_v2_op.cc index 253c2856063..6df6422f717 100644 --- a/paddle/fluid/operators/expand_v2_op.cc +++ b/paddle/fluid/operators/expand_v2_op.cc @@ -206,7 +206,7 @@ class ExpandV2CompositeGradOpMaker : public prim::CompositeGradOpMakerBase { auto shape = this->Attr>("shape"); prim::expand_grad( x, out_grad, paddle::experimental::IntArray(shape), x_grad_p); - VLOG(3) << "Runing expand_v2 composite func"; + VLOG(6) << "Runing expand_v2 composite func"; this->RecoverOutputName(x_grad, x_grad_name); } }; diff --git a/paddle/fluid/operators/generator/templates/operator_utils.c.j2 b/paddle/fluid/operators/generator/templates/operator_utils.c.j2 index a471efaa562..63392bb786f 100644 --- a/paddle/fluid/operators/generator/templates/operator_utils.c.j2 +++ b/paddle/fluid/operators/generator/templates/operator_utils.c.j2 @@ -665,7 +665,7 @@ class {{op_name | to_composite_grad_opmaker_name}} : public prim::CompositeGradO {%- endmacro %} {% macro call_composite_backward_api(composite_func_info) %} - VLOG(3) << "Runing {{composite_func_info["func_name"]}} composite func"; + VLOG(6) << "Runing {{composite_func_info["func_name"]}} composite func"; prim::{{composite_func_info["func_name"]}}({{composite_func_info["func_args"]}}); {%- endmacro %} diff --git a/paddle/fluid/operators/reduce_ops/reduce_sum_op.cc b/paddle/fluid/operators/reduce_ops/reduce_sum_op.cc index 9af1770a41d..5d14a0911fb 100644 --- a/paddle/fluid/operators/reduce_ops/reduce_sum_op.cc +++ b/paddle/fluid/operators/reduce_ops/reduce_sum_op.cc @@ -84,7 +84,7 @@ class ReduceSumCompositeGradOpMaker : public prim::CompositeGradOpMakerBase { // get output orginal name std::string x_grad_name = this->GetOutputName(x_grad_t); - VLOG(3) << "Runing sum_grad composite func"; + VLOG(6) << "Runing sum_grad composite func"; // call composite backward func prim::sum_grad( x, out_grad, axis, keep_dim, reduce_all, x_grad); diff --git a/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h b/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h index a7969382685..efb2479e405 100644 --- a/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h +++ b/paddle/fluid/prim/utils/static/composite_grad_desc_maker.h @@ -57,6 +57,8 @@ class CompositeGradOpMakerBase { acting_program_(framework::ProgramDesc()), grad_block_(grad_block) { // TODO(jiabin): This should always execute by one thread... + VLOG(6) << "Constructing Composite Grad func for " << fwd_op_.Type() + << "_grad "; StaticCompositeContext::Instance().SetBlock( acting_program_.MutableBlock(0)); } @@ -64,6 +66,7 @@ class CompositeGradOpMakerBase { virtual ~CompositeGradOpMakerBase() = default; virtual std::vector> operator()() { + VLOG(3) << "Runing Composite Grad func for " << fwd_op_.Type() << "_grad "; this->Apply(); std::vector> ops; // TODO(jiabin): Support multiple blocks later -- GitLab