From d6208aad900da90e9b5036b568d53a14f6e7ece4 Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Thu, 20 Oct 2022 09:58:45 +0200 Subject: [PATCH] log only if > 0 (#47181) --- paddle/fluid/framework/ir/fc_gru_fuse_pass.cc | 2 +- paddle/fluid/framework/ir/layer_norm_fuse_pass.cc | 3 ++- .../fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc | 3 ++- .../ir/mkldnn/conv_elementwise_add_mkldnn_fuse_pass.cc | 6 ++++-- .../fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc | 3 ++- .../ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc | 3 ++- .../ir/mkldnn/matmul_activation_mkldnn_fuse_pass.cc | 3 ++- .../ir/mkldnn/matmul_elementwise_add_mkldnn_fuse_pass.cc | 3 ++- paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass.cc | 3 ++- .../ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc | 3 ++- 10 files changed, 21 insertions(+), 11 deletions(-) diff --git a/paddle/fluid/framework/ir/fc_gru_fuse_pass.cc b/paddle/fluid/framework/ir/fc_gru_fuse_pass.cc index 7ec1227c12..e195870250 100644 --- a/paddle/fluid/framework/ir/fc_gru_fuse_pass.cc +++ b/paddle/fluid/framework/ir/fc_gru_fuse_pass.cc @@ -350,7 +350,7 @@ void FCGRUFusePass::ApplyImpl(ir::Graph* graph) const { graph, name_scope_, param_scope(), true /*with_fc_bias*/); AddStatis(fusion_count); - if (!Has("disable_logs") || !Get("disable_logs")) + if ((!Has("disable_logs") || !Get("disable_logs")) && fusion_count > 0) string::PrettyLogDetail("--- fused %d pairs of fc gru patterns", fusion_count); } diff --git a/paddle/fluid/framework/ir/layer_norm_fuse_pass.cc b/paddle/fluid/framework/ir/layer_norm_fuse_pass.cc index afc1178567..5df2306935 100644 --- a/paddle/fluid/framework/ir/layer_norm_fuse_pass.cc +++ b/paddle/fluid/framework/ir/layer_norm_fuse_pass.cc @@ -422,7 +422,8 @@ void LayerNormFusePass::ApplyImpl(Graph* graph) const { gpd(graph, handler); AddStatis(found_layer_norm_count); - if (!Has("disable_logs") || !Get("disable_logs")) + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_layer_norm_count > 0) PrettyLogDetail("--- Fused %d subgraphs into layer_norm op.", found_layer_norm_count); } diff --git a/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc index fa2bc4d374..02a394cafd 100644 --- a/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/batch_norm_act_fuse_pass.cc @@ -143,7 +143,8 @@ void FuseBatchNormActOneDNNPass::FuseBatchNormAct( gpd(graph, handler); AddStatis(found_bn_act_count); - if (!Has("disable_logs") || !Get("disable_logs")) + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_bn_act_count > 0) PrettyLogDetail("--- fused %d batch norm with relu activation", found_bn_act_count); } diff --git a/paddle/fluid/framework/ir/mkldnn/conv_elementwise_add_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/conv_elementwise_add_mkldnn_fuse_pass.cc index a9bc746680..6a3a24648d 100644 --- a/paddle/fluid/framework/ir/mkldnn/conv_elementwise_add_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/conv_elementwise_add_mkldnn_fuse_pass.cc @@ -140,7 +140,8 @@ GraphWithStats ResidualConnectionMKLDNNFusePass::FuseConv( }; gpd(graph_with_stats.first, handler); - if (!Has("disable_logs") || !Get("disable_logs")) { + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_conv_count > 0) { std::stringstream msg_ss; std::string fusionMode = as_x ? "x" : "y"; msg_ss << "--- Fused " << found_conv_count << " conv (as " << fusionMode @@ -228,7 +229,8 @@ GraphWithStats ResidualConnectionMKLDNNFusePass::FuseProjectionConv( }; gpd(graph_with_stats.first, handler); - if (!Has("disable_logs") || !Get("disable_logs")) { + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_projection_conv_count > 0) { std::stringstream msg_ss; msg_ss << "--- Fused " << found_projection_conv_count << " projection conv (as y) + elementwise_add patterns"; diff --git a/paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc index 3059be8a9a..ab481b2b94 100644 --- a/paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/elt_act_mkldnn_fuse_pass.cc @@ -99,7 +99,8 @@ void ElementwiseActivationOneDNNPass::FuseElementwiseAct( gpd(graph, handler); AddStatis(found_elementwise_activation_count); - if (!Has("disable_logs") || !Get("disable_logs")) + if ((!Has("disable_logs") || + !Get("disable_logs") && found_elementwise_activation_count > 0)) PrettyLogDetail("--- fused %d %s with %s activation", found_elementwise_activation_count, elt_type, diff --git a/paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc index 7e9a434be1..52e3e9b5d7 100644 --- a/paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/fc_elementwise_add_mkldnn_fuse_pass.cc @@ -132,7 +132,8 @@ GraphWithStats FCResidualConnectionMKLDNNFusePass::FuseFC( }; gpd(graph_with_stats.first, handler); - if (!Has("disable_logs") || !Get("disable_logs")) { + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_fc_count > 0) { std::stringstream msg_ss; std::string fusionMode = fc_as_x ? "x" : "y"; msg_ss << "--- Fused " << found_fc_count << " fc (as " << fusionMode diff --git a/paddle/fluid/framework/ir/mkldnn/matmul_activation_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/matmul_activation_mkldnn_fuse_pass.cc index 9ba89106c3..3609466cb4 100644 --- a/paddle/fluid/framework/ir/mkldnn/matmul_activation_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/matmul_activation_mkldnn_fuse_pass.cc @@ -87,7 +87,8 @@ void MatmulActivationMkldnnFusePass::FuseMatmulAct( gpd(graph, handler); AddStatis(found_matmul_activation_count); - if (!Has("disable_logs") || !Get("disable_logs")) { + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_matmul_activation_count > 0) { PrettyLogDetail("--- fused %d %s with %s activation", found_matmul_activation_count, matmul_type, diff --git a/paddle/fluid/framework/ir/mkldnn/matmul_elementwise_add_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/matmul_elementwise_add_mkldnn_fuse_pass.cc index 2e6e450cd4..a2a67c3aaf 100644 --- a/paddle/fluid/framework/ir/mkldnn/matmul_elementwise_add_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/matmul_elementwise_add_mkldnn_fuse_pass.cc @@ -82,7 +82,8 @@ void MatmulElementwiseAddMKLDNNFusePass::FuseMatmulElementwiseAdd( gpd(graph, handler); AddStatis(found_matmul_elementwise_add_count); - if (!Has("disable_logs") || !Get("disable_logs")) { + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_matmul_elementwise_add_count > 0) { PrettyLogDetail("--- fused %d %s (as %s) with elementwise_add", found_matmul_elementwise_add_count, matmul_type, diff --git a/paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass.cc index a968af26bd..e464d8d8db 100644 --- a/paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/scale_matmul_fuse_pass.cc @@ -135,7 +135,8 @@ void ScaleMatmulFusePass::ApplyImpl(ir::Graph* graph) const { }; gpd(graph, handler); AddStatis(found_scale_matmul_fuse_count); - if (!Has("disable_logs") || !Get("disable_logs")) + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_scale_matmul_fuse_count > 0) PrettyLogDetail("--- fused %d scale with matmul", found_scale_matmul_fuse_count); } diff --git a/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc b/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc index 77df45c8e0..90a886aece 100644 --- a/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/softplus_activation_mkldnn_fuse_pass.cc @@ -94,7 +94,8 @@ void SoftplusActivationOneDNNPass::FuseSoftplusActivation( gpd(graph, handler); AddStatis(found_softplus_activation_count); - if (!Has("disable_logs") || !Get("disable_logs")) + if ((!Has("disable_logs") || !Get("disable_logs")) && + found_softplus_activation_count > 0) PrettyLogDetail("--- fused %d softplus with %s activation", found_softplus_activation_count, act_type); -- GitLab