From commits-return-16351-archive-asf-public=cust-asf.ponee.io@tvm.apache.org Fri Jun 26 00:02:20 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id D6B2E180181 for ; Fri, 26 Jun 2020 02:02:19 +0200 (CEST) Received: (qmail 20958 invoked by uid 500); 26 Jun 2020 00:02:19 -0000 Mailing-List: contact commits-help@tvm.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tvm.apache.org Delivered-To: mailing list commits@tvm.apache.org Received: (qmail 20948 invoked by uid 99); 26 Jun 2020 00:02:19 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jun 2020 00:02:19 +0000 From: =?utf-8?q?GitBox?= To: commits@tvm.apache.org Subject: =?utf-8?q?=5BGitHub=5D_=5Bincubator-tvm=5D_comaniac_commented_on_a_change_in?= =?utf-8?q?_pull_request_=235931=3A_Add_TupleGetItem_to_CSE?= Message-ID: <159312973918.8807.17023673629688237090.asfpy@gitbox.apache.org> Date: Fri, 26 Jun 2020 00:02:19 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit In-Reply-To: References: comaniac commented on a change in pull request #5931: URL: https://github.com/apache/incubator-tvm/pull/5931#discussion_r445901105 ########## File path: src/relay/transforms/eliminate_common_subexpr.cc ########## @@ -58,27 +58,52 @@ class CommonSubexprEliminator : public ExprMutator { auto it = expr_map_.find(new_call->op); if (it != expr_map_.end()) { - for (const CallNode* candidate : it->second) { - bool is_equivalent = true; - if (!attrs_equal(new_call->attrs, candidate->attrs)) { - continue; + for (const Expr& candidate_expr : it->second) { + if (const CallNode* candidate = candidate_expr.as()) { + bool is_equivalent = true; + if (!attrs_equal(new_call->attrs, candidate->attrs)) { + continue; + } + for (size_t i = 0; i < new_call->args.size(); i++) { + if (!new_call->args[i].same_as(candidate->args[i]) && + !IsEqualScalar(new_call->args[i], candidate->args[i])) { + is_equivalent = false; + break; + } + } + if (!is_equivalent) continue; + return GetRef(candidate); } - for (size_t i = 0; i < new_call->args.size(); i++) { - if (!new_call->args[i].same_as(candidate->args[i]) && - !IsEqualScalar(new_call->args[i], candidate->args[i])) { - is_equivalent = false; - break; + } + } + expr_map_[new_call->op].push_back(new_expr); + return new_expr; + } + + Expr VisitExpr_(const TupleGetItemNode* op) final { + Expr new_expr = ExprMutator::VisitExpr_(op); + const TupleGetItemNode* new_tuple = new_expr.as(); Review comment: `new_tuple` is a bit confusing as this is not actually a `tuple`. Maybe `new_tuple_item` would be better? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org