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 18BC6200D2B for ; Thu, 19 Oct 2017 04:16:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1727D160BEB; Thu, 19 Oct 2017 02:16:06 +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 0EBA1160BEA for ; Thu, 19 Oct 2017 04:16:04 +0200 (CEST) Received: (qmail 43684 invoked by uid 500); 19 Oct 2017 02:16:04 -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 43672 invoked by uid 99); 19 Oct 2017 02:16:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Oct 2017 02:16:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 12297180694 for ; Thu, 19 Oct 2017 02:16:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.85 X-Spam-Level: X-Spam-Status: No, score=0.85 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_REPLY=1, 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, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-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 (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id smyEhSScWTPK for ; Thu, 19 Oct 2017 02:15:58 +0000 (UTC) Received: from mail-io0-f174.google.com (mail-io0-f174.google.com [209.85.223.174]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id C52A75FB57 for ; Thu, 19 Oct 2017 02:15:57 +0000 (UTC) Received: by mail-io0-f174.google.com with SMTP id n137so8364027iod.6 for ; Wed, 18 Oct 2017 19:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=Dx4V/MAVuGUPONap+1GOaEzV5wYW65bwJ3rrwH6WCmE=; b=r15tgU/DvwADE8XiaPXuFWqQAiMdQ1osf4lgXkUFZKPij4reS3K0Ivix9fLPZZ6czk SpwaXTO+yek6EC0fFcZ9Pwklm5KSjWE5F2diNcWy3ClVaBw9Q9C48p+809lpJij7Z+Wy GXIMtfxaW+EGMAMiCrahP+EdH4riCPwUnwCA2Az5jt6dRfuHRTFXYmeF75gCWUz5Itq9 8oZkeJkoYJ7+WSLsMsyb7GxxWncTH6cqs061nQgx2YqmbkfGk3W3jCBivnovPGuSoFXn 0+YNUIVYc3SeZcsq5JR+WdY1SX6gm15SDqHp2ocV/Nee+MVfwN6pNONLorPLbFeRSNdk +AIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=Dx4V/MAVuGUPONap+1GOaEzV5wYW65bwJ3rrwH6WCmE=; b=NbZBlGCjGcWhRc/6xACyfXYgzpJlTNR9/CDpriQp0TNUZQjtKs1lVfbCBQ2a1WVYTQ kncxjW4ddmQ18zgUkqfR05L6gxhFfXtFdWoykE9y+w3Ok/Z7vVpfWj9ICtIvkzlOkB2H wdy079MXnupYkw4Z8HPpTu7xlUjZF4ZfI01TMMsePlcnjheHdSE45oUIMfw7W+4najvT OZfIQcfZI20oek6XzApx0CpL2jGxs6KhsV4uREFhU2XYKz0XZgrQzc+RoQM7HVXJT4ai lJ5+d9+vZAqQUn1FVEttwtf4Knu4eI1tgyt9qxT9vH/cyHgClFuOEJFHhgHsbUlXr94S y9KQ== X-Gm-Message-State: AMCzsaX7mTltnimvBCY1Z9shhUtQQmUCkWoUJ0Ax4eArHtssoyyg60P/ GcFUKK5PaFUKRiKm/sWn/Wsy5CJ8LWVEiuU2pX4= X-Google-Smtp-Source: ABhQp+RNrQUUjggp0nFF3QXj+HzFViltSaQhcwUrwoM/6pIixgktJbhtpECga4sI6TVvytApZPCWYcrglEoM8ZGsV9I= X-Received: by 10.107.107.21 with SMTP id g21mr63828ioc.101.1508379356988; Wed, 18 Oct 2017 19:15:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Chris Olivier Date: Thu, 19 Oct 2017 02:15:46 +0000 Message-ID: Subject: Re: Request for suggestions- Supporting onnx in mxnet To: dev@mxnet.incubator.apache.org Content-Type: multipart/alternative; boundary="089e0825e940c28af1055bdcef96" archived-at: Thu, 19 Oct 2017 02:16:06 -0000 --089e0825e940c28af1055bdcef96 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Reduce code base of mxnet? By increasing scope of the dmlc modules? Is the intent to make mxnet a thin language wrapper around a group of dmlc modules? On Wed, Oct 18, 2017 at 6:58 PM Tianqi Chen wrote: > To better answer Hagay's question, I would like to dive down a bit deeper > on the relation between MXNet, NNVM and model exchange format like ONNX. > > There are two major trends in deep learning systems now: > > - Common serializable formats, like ONNX and CoreML, that defines the mod= el > exchange format. > - The in-memory graph IR for quick optimization and JIT. NNVM, Tensorflow= 's > XLA falls into this category. > > The exchange formats are great, it only poses a layer of conversion, whic= h > is good for exchange. The real meat still comes from the compilation and > JIT pipeline you have to offer. For that, we will need an in-memory IR, > because of the cost of constructing, serialize could be high for the > exchange formats like protobuf. And usually, the exchange formats are > designed in a minimalistic fashion, making it less easy to extend more > information to support in-depth optimization like automatic quantization, > accelerator support. > > The current MXNet relies on NNVM for in-memory IR manipulation but does n= ot > contain a compilation component that compiles to the hardware backends. > Doing export to an exchange format and then back into NNVM run the > compilation poses too much burden that JIT compiler could pay. Using the > same in-memory graph IR as the compilation stack give much more advantage > in terms of this. > > The newly introduces nnvm/top and compiler offers in-memory graph > optimization and compilation and offers more hardware backend directly vi= a > TVM. We already see promising results in edge deployments with a much low= er > overhead of runtime. We will further benefit quickly from more graph > optimizations that it has to offer. > > Building support around this new paradigm offers us advantage of being > future compatible and takes full benefit of the points I mentioned above > > Tianqi > > > > On Wed, Oct 18, 2017 at 4:57 PM, Lupesko, Hagay wrote= : > > > Roshani =E2=80=93 this is an exciting initiative, ONNX support on MXNet= will > > enable more users to ramp up on MXNet, which is great. > > > > Tianqi =E2=80=93 a few questions and thoughts about your note: > > - =E2=80=9CMore hardware backends to mxnet=E2=80=9D =E2=80=93 MXNet use= rs get the same benefit of > > HW support implementing ONNX import on top of MXNet symbolic, right? > > - =E2=80=9CNNVM Compiler now received contributions from AWS, UW and ma= ny other > > folks in MXNet community.=E2=80=9D =E2=80=93 agreed it is ramping up, b= ut when you look > at > > the data, it is clear that it is very early on for NNVM. Looking at the > > repo, it has overall 223 commits, 0 releases. Compare it to MXNet with > 6136 > > commits and 32 releases. It seems to be still early on for NNVM, and fo= r > a > > more reliable initial implementation building the import on top of MXNe= t > is > > easier, faster and safer. MXNet has lots of users already using the > > Symbolic API which hopefully mean that is a mature API that is not like= ly > > to have breaking changes or major issues. > > > > I=E2=80=99m supportive option 1 proposed by Roshani (building serde on = top of > > MXNet symbolic), but to do it as an encapsulated implementation detail, > so > > the implementation can be migrated to NNVM or another implementation in > the > > future, if at that point it seems like the right thing to do. > > > > Interested in hearing other opinions though=E2=80=A6 > > > > Hagay > > > > On 10/18/17, 14:13, "Tianqi Chen" > tqchen@cs.washington.edu> wrote: > > > > 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, Raspber= ry > > Pi, > > web browser. These things are automatically enabled by going throug= h > > this > > layer. In general, we design nnvm/tvm stack to resolve the challeng= e > of > > current mxnet's weakness in terms deploying to more hardware > backends. > > > > - More frontend capabilities, nnvm's gluon style IR ingests now fro= m > > 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 regar= d > to > > nnvm/tvm stack > > > > 1. Nascent project with few contributors > > > > NNVM Compiler now received contributions from AWS, UW and many othe= r > > 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 AP= I > > > > 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 i= s > > well > > tested on CPU and GPU cases for front-ends. > > > > Tianqi > > > > > > On Wed, Oct 18, 2017 at 1:41 PM, Roshani Nagmote < > > roshaninagmote2@gmail.com> > > wrote: > > > > > Hi guys, > > > > > > > > > I am working on supporting ONNX > > pre-trained > > > 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, this > > > 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 for= mat 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 > > expose > > > a MXNet python module =E2=80=9Cserde=E2=80=9D(name taken from Apa= che 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 > > functionality. > > > 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 alread= y) > > > 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 o= f > > the > > > users. > > > > > > Cons: > > > > > > 1. > > > > > > In the future we may have to reimplement at the nnvm/tvm layer= , > > in case > > > 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 A= PIs 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 AP= I > > > 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, this > > > will be an implementation detail that is not exposed. > > > > > > Thanks, > > > > > > Roshani > > > > > > > > > > > > --089e0825e940c28af1055bdcef96--