From 41acf19b58669be116b67902ac3345b128511262 Mon Sep 17 00:00:00 2001 From: jiangfan06 <117341294+MuShangCC@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:35:27 +0800 Subject: [PATCH] Fix identity_op_clean_pass (#56753) --- paddle/fluid/framework/ir/identity_op_clean_pass.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/ir/identity_op_clean_pass.cc b/paddle/fluid/framework/ir/identity_op_clean_pass.cc index 255d1b06ea0..152ac086036 100644 --- a/paddle/fluid/framework/ir/identity_op_clean_pass.cc +++ b/paddle/fluid/framework/ir/identity_op_clean_pass.cc @@ -124,7 +124,14 @@ FindTwoCastOpPattern::FindTwoCastOpPattern(PDPattern* pattern, }); auto* cast_op_1 = pattern->NewNode(cast_op_1_repr())->assert_is_op("cast"); - auto* cast_op_1_out = pattern->NewNode(cast_op_1_out_repr())->assert_is_var(); + auto* cast_op_1_out = pattern->NewNode(cast_op_1_out_repr()) + ->assert_is_var() + ->assert_is_op_output("cast", "Out") + ->assert_more([](Node* x) { + const auto& var_type = x->Var()->GetDataType(); + return var_type != proto::VarType::INT32 && + var_type != proto::VarType::INT64; + }); auto* cast_op_2 = pattern->NewNode(cast_op_2_repr())->assert_is_op("cast"); auto* cast_op_2_out = pattern->NewNode(cast_op_2_out_repr())->assert_is_var(); -- GitLab