From e9bb31263979e6b76338b4d4c9fe2ac262d692fa Mon Sep 17 00:00:00 2001 From: csy0225 <78470701+csy0225@users.noreply.github.com> Date: Thu, 24 Aug 2023 20:05:43 +0800 Subject: [PATCH] [XPU] Fix matmul + elementwise_add + bn + act fusion that elementwise_add has branch. (#56578) --- paddle/fluid/framework/ir/xpu/fc_xpu_fuse_pass.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/paddle/fluid/framework/ir/xpu/fc_xpu_fuse_pass.cc b/paddle/fluid/framework/ir/xpu/fc_xpu_fuse_pass.cc index 59e7f4f7de5..4c8424b7df0 100644 --- a/paddle/fluid/framework/ir/xpu/fc_xpu_fuse_pass.cc +++ b/paddle/fluid/framework/ir/xpu/fc_xpu_fuse_pass.cc @@ -128,6 +128,9 @@ FcXPUPattern::FcXPUPattern(PDPattern* pattern, add_out = pattern->NewNode(add_out_repr()) ->assert_is_op_output("elementwise_add", "Out") ->assert_var_not_persistable(); + if (with_bn_ || !act_type_.empty()) { + add_out->assert_has_n_outputs(1); + } add->LinksFrom({mul_out, bias}).LinksTo({add_out}); } else { add_out = mul_out; -- GitLab