From bfb8a64234217643f758b6154eedc2a0e2d2665b Mon Sep 17 00:00:00 2001 From: alncat Date: Mon, 1 Mar 2021 15:45:15 +0800 Subject: [PATCH] updated conv bn fuse pass to make it compatible with latest batch_norm op (#31272) --- .../fluid/framework/ir/graph_pattern_detector.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/framework/ir/graph_pattern_detector.cc b/paddle/fluid/framework/ir/graph_pattern_detector.cc index a38f10ba408..deb182c0fbe 100644 --- a/paddle/fluid/framework/ir/graph_pattern_detector.cc +++ b/paddle/fluid/framework/ir/graph_pattern_detector.cc @@ -790,27 +790,31 @@ PDNode *patterns::ConvBN::operator()(paddle::framework::ir::PDNode *conv_input, auto *bn_scale_var = pattern->NewNode(bn_scale_repr()) ->AsInput() ->assert_is_persistable_var() - ->assert_is_op_input("batch_norm", "Scale"); + ->assert_is_op_input("batch_norm", "Scale") + ->assert_has_n_outputs(1); // BN Bias auto *bn_bias_var = pattern->NewNode(bn_bias_repr()) ->AsInput() ->assert_is_persistable_var() - ->assert_is_op_input("batch_norm", "Bias"); + ->assert_is_op_input("batch_norm", "Bias") + ->assert_has_n_outputs(1); // BN Mean auto *bn_mean_var = pattern->NewNode(bn_mean_repr()) ->AsInput() ->assert_is_persistable_var() - ->assert_is_op_input("batch_norm", "Mean"); + ->assert_is_op_input("batch_norm", "Mean") + ->assert_has_n_outputs(1); // BN Variance auto *bn_variance_var = pattern->NewNode(bn_variance_repr()) ->AsInput() ->assert_is_persistable_var() - ->assert_is_op_input("batch_norm", "Variance"); + ->assert_is_op_input("batch_norm", "Variance") + ->assert_has_n_outputs(1); // BN output auto *bn_out_var = pattern->NewNode(bn_out_repr()) ->AsOutput() - ->assert_is_op_output("batch_norm"); + ->assert_is_op_output("batch_norm", "Y"); auto *bn_mean_out_var = pattern->NewNode(bn_mean_out_repr()) ->AsOutput() -- GitLab