Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9B0BA200D1E for ; Wed, 18 Oct 2017 23:13:41 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 99955160BEA; Wed, 18 Oct 2017 21:13:41 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DD1231609DE for ; Wed, 18 Oct 2017 23:13:40 +0200 (CEST) Received: (qmail 15430 invoked by uid 500); 18 Oct 2017 21:13:40 -0000 Mailing-List: contact dev-help@mxnet.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@mxnet.incubator.apache.org Delivered-To: mailing list dev@mxnet.incubator.apache.org Received: (qmail 15418 invoked by uid 99); 18 Oct 2017 21:13:39 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Oct 2017 21:13:39 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 0187DC07F7 for ; Wed, 18 Oct 2017 21:13:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.3 X-Spam-Level: X-Spam-Status: No, score=-0.3 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-2.8, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Mnnhcg8j9XqP for ; Wed, 18 Oct 2017 21:13:37 +0000 (UTC) Received: from mail-io0-f171.google.com (mail-io0-f171.google.com [209.85.223.171]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 0B2615F3DE for ; Wed, 18 Oct 2017 21:13:37 +0000 (UTC) Received: by mail-io0-f171.google.com with SMTP id 97so7730129iok.7 for ; Wed, 18 Oct 2017 14:13:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to; bh=2fP9pLNI6get7CXGdKpiLK0DGFFaFa+LhziM19jvZUU=; b=t2QbUityTFkteKHFxMUI4mBZ/Vd7KM3xZGQiFWfB/4wVP/IxWU3MbwjjY12qHrGn55 MJaxty7YdYSPOn1uT/HweVDlhULrz+CwDHb+oQ6lttKjtGIbIA2ANYDnrrrjh4hv/S84 zijMnJ9rDBSXD7afYeYojQTH8+AdyZcWvYNQ286fdUN+Ve2NL0X9lPDuthpBylXkFJDZ yRAILd0MAityJVfiQwXPP5YiL3BqFP46fYaL26gvmHzbIEOiJx53yoi8q0FjdM6ldSNd dm1b1V3KkhCQErQ06WLyNbuAsWB9qdPyjbsSPcXPIcySLgEnemRr/VL5G5KnEny85+E6 siMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to; bh=2fP9pLNI6get7CXGdKpiLK0DGFFaFa+LhziM19jvZUU=; b=erIJ79AT+4hcshb+99yVEXOyYsucnBp7YPyfguvzWXnXsucGnQ+/1uobCvlYrSPehf NUCQEzfxCujembCVMVCo1zQCo/NGCWlc7D0OkYTE4bOy1wRR7KA7aULilfWf/JLSTXa/ sFAwAhk6b8kcJhfMPZw+TkTE01Cmd12Hkj9qq3IuZvo+eaiy1r43wSbVk2I0SodwBwfv Kic6PkGlN5XOt6wWwtHrhF6lJK24OzjQOIvU8yik+9D6Ju72tWnXHNQJBckUaPD9www1 hmG5rtuOMXcYLV2y0czYBBj8YAgglLQD3T/gx14hcDaKDpRzYZGRLssq+n3OYcmAKH11 W3zg== X-Gm-Message-State: AMCzsaV+fVMGVdWUUu29DOInv3FImDNJYV/kQn6TdWd8b/3NvoTnNpfI pSwtYgOzGcMBP0sW3uTwX20OmDEUp8XcPA4fu/wcpA== X-Google-Smtp-Source: ABhQp+S4tyDxJ0MJr/zPRr9pCW11k6lHi4Uz1I4RN076D6SqFlGqE/MMzS3Pzlvql92TQabBGKo3XaguGZn4LpniSr4= X-Received: by 10.107.141.215 with SMTP id p206mr24916308iod.267.1508361215926; Wed, 18 Oct 2017 14:13:35 -0700 (PDT) MIME-Version: 1.0 Sender: workcrow@gmail.com Received: by 10.2.96.33 with HTTP; Wed, 18 Oct 2017 14:13:35 -0700 (PDT) In-Reply-To: References: From: Tianqi Chen Date: Wed, 18 Oct 2017 14:13:35 -0700 X-Google-Sender-Auth: mywhz0sJzuDYwiLTjy5kz4DO3tE Message-ID: Subject: Re: Request for suggestions- Supporting onnx in mxnet To: dev@mxnet.incubator.apache.org Content-Type: multipart/alternative; boundary="94eb2c05d86677e62a055bd8b6a3" archived-at: Wed, 18 Oct 2017 21:13:41 -0000 --94eb2c05d86677e62a055bd8b6a3 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I am strongly recommending going through the nnvm/top. One major reason in here is that the support of nnvm/top layer NOT ONLY mean compatibility of model format with onnx. These are the major benefits: - More hardware backends to mxnet, including opencl, metal, Raspberry Pi, web browser. These things are automatically enabled by going through this layer. In general, we design nnvm/tvm stack to resolve the challenge of current mxnet's weakness in terms deploying to more hardware backends. - More frontend capabilities, nnvm's gluon style IR ingests now from CoreML, ONNX and in future keras. Supporting those will reduce the amount of engineering effort needed. - Future compatibility. We all agree that the future being migrated to gluon's API. NNVM/top tries to look ahead by directly adopting the symbolic API to be gluon. I would also like to correct some of the mentioned facts with regard to nnvm/tvm stack 1. Nascent project with few contributors NNVM Compiler now received contributions from AWS, UW and many other folks in MXNet community. NNVM itself is already being used by MXNet. MXNet's internal IR is migrating toward gluon, and its final form being nnvm/top 3. Does not support all operators that exist in MXNet Symbolic API Neither NNVM/top or onnx support all operators that exist in mxnet symbolic API. The end goal here is mainly to make nnvm/top onnx compatible, which is a more reasonable goal. 4. No CI Pipeline and testcases NNVM already contains a compiler contains unittests and ci tested with integration https://github.com/dmlc/nnvm, with a CI pipline that is well tested on CPU and GPU cases for front-ends. Tianqi On Wed, Oct 18, 2017 at 1:41 PM, Roshani Nagmote wrote: > Hi guys, > > > I am working on supporting ONNX pre-traine= d > models in Apache MXNet and would like to seek your opinion on the choice = of > implementation. I also have created a GitHub issue > . Supporting ONNX > in > MXNet will enable users to move between frameworks with their models, thi= s > will also enable MXNet project to be a part of the ONNX open standard and > steer the direction of ONNX. > > > For those who don=E2=80=99t know ONNX, ONNX is an open source format for = AI models > which enables models to be transferred between frameworks. Refer to > https://github.com/onnx/onnx for more details. > > > To implement the import/export functionality in MXNet, I propose to expos= e > a MXNet python module =E2=80=9Cserde=E2=80=9D(name taken from Apache Hive= project) with the > following methods supporting different formats: > > sym, params =3D mxnet.serde.import(other_format_file, other_format=3D=E2= =80=98onnx=E2=80=99) > > other_format_file =3D mxnet.serde.export(mxnet_sym, mxnet_params, =E2=80= =98onnx=E2=80=99) > > > The implementation under the hood can be done in two ways: > > > 1) Implement at the MXNet layer by parsing the ONNX model(in protobuf > format) and turn into MXNet Symbolic operators and build MXNet model > directly. Similarly, I can convert the MXNet model to ONNX format at this > layer. > > > 2) The DMLC community has released the nnvm/tvm complier and an > intermediate representation of the models, refer: > http://www.tvmlang.org/2017/10/06/nnvm/tvm-compiler-announcement.html > > > Based on the conversation on the GitHub issue > I opened, Mu > mentioned that MXNet would use nnvm/tvm as the backend in the future. > > > We could hook into this layer to implement the import/export functionalit= y. > nnvm/tvm has ONNX 0.1 version import implemented. > > For import, > > 1. > > I will need to enhance nnvm/tvm=E2=80=99s importer to support ONNX 0.2 > 2. > > Implement nnvm/tvm->mxnet symbolic operators. > > For export: > > > 1. > > mxnet->nnvm/tvm ( nnvm/tvm provides this implementation already) > 2. > > I will need to Implement nnvm/tvm>onnx. > > > These are the pros and cons I see in the above approaches: > > 1. > > Import/export at mxnet layer > > Pros: > > 1. > > Stable APIs currently used by users. > 2. > > Larger Apache MXNet community of contributors. > 3. > > CI pipeline to catch bugs. > 4. > > Comparatively less time to implement and put it in the hands of the > users. > > Cons: > > 1. > > In the future we may have to reimplement at the nnvm/tvm layer, in cas= e > MXNet moves to the nnvm/tvm backend(assuming it will move). > > > > 1. > > Import/export at nnvm/tvm layer > > Pros: > > 1. > > Less engineering work in case mxnet moves to nnvm/tvm > 2. > > nnvm/tvm would become a hub to convert to different formats. > 3. > > nnvm operators are more in parity with mxnet=E2=80=99s gluon APIs this= could be > useful in case Gluon becomes the only standard that MXNet will support= . > > Cons: > > 1. > > Nascent project with few contributors > 2. > > Does not support all operators that exist in MXNet Symbolic API > 3. > > No CI Pipeline > 4. > > Current Apache MXNet project does not use nnvm/tvm backend > 5. > > mxnet->nnvm/tvm backend needs more testing and user feedback. > > > Any suggestions on both of these approaches? From user's perspective, thi= s > will be an implementation detail that is not exposed. > > Thanks, > > Roshani > --94eb2c05d86677e62a055bd8b6a3--