From c534149642d2f34b94968d51aecd3373d3790f7c Mon Sep 17 00:00:00 2001 From: Wilber Date: Sat, 2 Nov 2019 22:33:23 +0800 Subject: [PATCH] fix squared_mat_sub_fuse_pass when elementwise_op input is from persistable param test=develop (#20960) fix squared_mat_sub_fuse_pass when elementwise_op input is from 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 42f4a91a6f..6d908b4362 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