From e6ed637994f006ea6a2f15567813f915a1e585ed Mon Sep 17 00:00:00 2001 From: Wilber Date: Thu, 7 Nov 2019 14:47:04 +0800 Subject: [PATCH] [cherry-pick] fix squared_mat_sub_fuse_pass bug when elementwise_op input is persistable param test=develop test=release/1.6 (#21044) fix squared_mat_sub_fuse_pass bug when elementwise_op input is persistable param --- paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc b/paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc index 42f4a91a6f4..6d908b4362b 100644 --- a/paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc +++ b/paddle/fluid/framework/ir/squared_mat_sub_fuse_pass.cc @@ -240,7 +240,8 @@ PDNode* BuildSquaredMatSubPattern(PDPattern* pattern, return false; } for (auto* in : x->inputs) { - if (in && in->inputs[0] && is_fusion_sub_op(in->inputs[0])) { + if (in && in->inputs.size() > 0 && in->inputs[0] && + is_fusion_sub_op(in->inputs[0])) { return true; } } @@ -262,7 +263,7 @@ PDNode* BuildSquaredMatSubPattern(PDPattern* pattern, auto* constant_op_out = pattern->NewNode( [=](Node* x) { return x && x->IsVar() && var_is_op_input(x, "elementwise_mul") && - x->inputs[0] && x->inputs[0]->IsOp() && + x->inputs.size() > 0 && x->inputs[0] && x->inputs[0]->IsOp() && x->inputs[0]->Op()->Type() == "fill_constant" && x->outputs[0] && is_fusion_element_op(x->outputs[0]); }, -- GitLab