From commits-return-11317-archive-asf-public=cust-asf.ponee.io@tvm.apache.org Tue Apr 14 00:34:37 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 03140180677 for ; Tue, 14 Apr 2020 02:34:36 +0200 (CEST) Received: (qmail 79711 invoked by uid 500); 14 Apr 2020 00:34:36 -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 79668 invoked by uid 99); 14 Apr 2020 00:34:36 -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; Tue, 14 Apr 2020 00:34:36 +0000 From: GitBox To: commits@tvm.apache.org Subject: [GitHub] [incubator-tvm] zhiics commented on a change in pull request #5324: [Runtime][Relay][Cleanup] Clean up for memory pass to enable heterogenous execution support. Message-ID: <158682447632.32465.14678047699438134473.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Tue, 14 Apr 2020 00:34:36 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit zhiics commented on a change in pull request #5324: [Runtime][Relay][Cleanup] Clean up for memory pass to enable heterogenous execution support. URL: https://github.com/apache/incubator-tvm/pull/5324#discussion_r407796859 ########## File path: python/tvm/relay/op/memory/memory.py ########## @@ -96,3 +100,53 @@ def shape_func(func, inputs, outputs, dependent=False): The shape function expression. """ return _make.shape_func(func, inputs, outputs, dependent) + +def flatten_tuple_type(ty): + """Return a sequence of the types contained in the tuple type in order. + + Parameters + ---------- + ty: tvm.Type + The type to flatten. + + Returns + ------- + result: List[tvm.Type] + The types in their linear order. + """ + return _make.FlattenTupleType(ty) + +def from_tuple_type(ty, expr): + """Convert an expression with the given type into a sequence of expressions. + Each expressions maps to a field of the tuple or nested tuples in linear + order. + + Parameters + ---------- + ty: tvm.Type + The type to unpack. + expr: The expression from which to extract each sub-field. + + Returns + ------- + result: List[tvm.relay.Expr] + The list of sub-expressions. + """ + return _make.FromTupleType(ty, expr) + +def to_tuple_type(ty, exprs): + """Pack the sequence of expressions into the nested tuple type. + + Parameters + ---------- + ty: tvm.Type + The type to pack with. + + exprs: The expressions to pack back into the nested tuple type. + + Returns + ------- + result: List[tvm.relay.Expr] + The packed tuple expression. Review comment: ```suggestion The packed tuple expression. ``` ---------------------------------------------------------------- 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 With regards, Apache Git Services