From ee24bffe86e8940c1892b1eb06a56c90288adab7 Mon Sep 17 00:00:00 2001 From: zyfncg Date: Mon, 6 Nov 2023 09:36:50 +0800 Subject: [PATCH] [DRR] Fix bug of matching source pattern in DRR (#58673) * fix bug of drr * fix bug --- paddle/fluid/pir/drr/drr_rewrite_pattern.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/pir/drr/drr_rewrite_pattern.cc b/paddle/fluid/pir/drr/drr_rewrite_pattern.cc index 99fc5e6906f624..e1b94bb77a0824 100644 --- a/paddle/fluid/pir/drr/drr_rewrite_pattern.cc +++ b/paddle/fluid/pir/drr/drr_rewrite_pattern.cc @@ -271,11 +271,19 @@ bool DrrRewritePattern::MatchFromOutputToInput( break; } // bfs producer_op of current_op - if (!drr_visited.count(drr_producer_op)) { + if (drr_visited.count(drr_producer_op) && + ir_visited.count(ir_producer_op)) { + continue; + } + if (!drr_visited.count(drr_producer_op) && + !ir_visited.count(ir_producer_op)) { drr_q.push(drr_producer_op); ir_q.push(ir_producer_op); drr_visited.insert(drr_producer_op); ir_visited.insert(ir_producer_op); + } else { + matched = false; + break; } } // binding output tensor of current_op