From commits-return-15570-archive-asf-public=cust-asf.ponee.io@tvm.apache.org Wed Jun 17 06:15:48 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 A886F180608 for ; Wed, 17 Jun 2020 08:15:48 +0200 (CEST) Received: (qmail 95091 invoked by uid 500); 17 Jun 2020 06:15:48 -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 95081 invoked by uid 99); 17 Jun 2020 06:15:48 -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; Wed, 17 Jun 2020 06:15:48 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id E6FBE890AF; Wed, 17 Jun 2020 06:15:47 +0000 (UTC) Date: Wed, 17 Jun 2020 06:15:47 +0000 To: "commits@tvm.apache.org" Subject: [incubator-tvm] branch v0.6 updated: [BACKPORT-0.6] Add ConstantNode to IsAtomic (#5831) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <159237454759.12196.744347131779414096@gitbox.apache.org> From: tqchen@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: incubator-tvm X-Git-Refname: refs/heads/v0.6 X-Git-Reftype: branch X-Git-Oldrev: baabee5eadef38f72c00c041901d53a6d191fe3a X-Git-Newrev: ce56d5b8d335f78f755640d18dc41222d83b3c1b X-Git-Rev: ce56d5b8d335f78f755640d18dc41222d83b3c1b X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. tqchen pushed a commit to branch v0.6 in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git The following commit(s) were added to refs/heads/v0.6 by this push: new ce56d5b [BACKPORT-0.6] Add ConstantNode to IsAtomic (#5831) ce56d5b is described below commit ce56d5b8d335f78f755640d18dc41222d83b3c1b Author: Zhi <5145158+zhiics@users.noreply.github.com> AuthorDate: Tue Jun 16 23:15:36 2020 -0700 [BACKPORT-0.6] Add ConstantNode to IsAtomic (#5831) * [Fix] Add ConstantNode to IsAtomic (#5457) * add constantnode to atomic * Add ToANormalForm to FoldConstant * fix test --- src/relay/pass/fold_constant.cc | 1 + tests/python/relay/test_pass_fold_constant.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/relay/pass/fold_constant.cc b/src/relay/pass/fold_constant.cc index b034c56..5d3ec03 100644 --- a/src/relay/pass/fold_constant.cc +++ b/src/relay/pass/fold_constant.cc @@ -184,6 +184,7 @@ class ConstantFolder : public ExprMutator { // Constant evaluate a expression. Expr ConstEvaluate(Expr expr) { std::vector passes = {transform::FuseOps(0), + transform::ToANormalForm(), transform::InferType()}; Function func; if (expr.as()) { diff --git a/tests/python/relay/test_pass_fold_constant.py b/tests/python/relay/test_pass_fold_constant.py index 4752597..5167ff2 100644 --- a/tests/python/relay/test_pass_fold_constant.py +++ b/tests/python/relay/test_pass_fold_constant.py @@ -29,6 +29,25 @@ def run_opt_pass(expr, opt_pass): return entry if isinstance(expr, relay.Function) else entry.body +def test_concatenate_const(): + def before(): + data = tvm.nd.array(np.array([1.0, 2.0, 3.0])) + const = relay.const(data) + concat = relay.op.concatenate([const, const], axis=0) + func = relay.Function([], concat) + return func + + def expected(): + data = tvm.nd.array(np.array([1.0, 2.0, 3.0, 1.0, 2.0, 3.0])) + const = relay.const(data) + func = relay.Function([], const) + return func + + zz = run_opt_pass(before(), transform.FoldConstant()) + zexpected = run_opt_pass(expected(), transform.InferType()) + assert relay.analysis.graph_equal(zz, zexpected) + + def test_fold_const(): c_data = np.array([1, 2, 3]).astype("float32") t = relay.TensorType([1, 2, 3], "float32")