Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[MXNET-121] Docs page for ONNX module. #10140

Merged
merged 6 commits into from
Apr 2, 2018

Conversation

anirudhacharya
Copy link
Member

@anirudhacharya anirudhacharya commented Mar 16, 2018

Description

Documentation page for ONNX module.

Checklist

Essentials

  • Passed code style checking (make lint)
  • Changes are complete (i.e. I finished coding on this PR)
  • All changes have test coverage:
  • Unit tests are added for small changes to verify correctness (e.g. adding a new operator)
  • Nightly tests are added for complicated/long-running ones (e.g. changing distributed kvstore)
  • Build tests will be added for build configuration changes (e.g. adding a new build option with NCCL)
  • Code is well-documented:
  • For user-facing API changes, API doc string has been updated.
  • For new C++ functions in header files, their functionalities and arguments are documented.
  • For new examples, README.md is added to explain the what the example does, the source of the dataset, expected performance on test set and reference to the original paper if applicable
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Documentation page for onnx module in contrib.

Comments

@@ -0,0 +1,111 @@
# ONNX API
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ONNX-MXNet Converter API ?
Please check the rendered output and fix the markdown

I think this can be created as a notebook, which users can use as a tutorial

```

```eval_rst
.. note:: **Install ONNX** which needs protobuf compiler to be installed separately. Please **follow the instructions to install ONNX** [here](https://github.com/onnx/onnx).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mark down render check?

.. note:: **Install ONNX** which needs protobuf compiler to be installed separately. Please **follow the instructions to install ONNX** [here](https://github.com/onnx/onnx).
```

This document describes the ONNX APIs in mxnet.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ONNX-MXNet API

Copy link
Contributor

@rajanksin rajanksin Mar 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit confusing as we are not describing ONNX API's . May be something like
"This document describes APIs to support ONNX in MXNet"

mxnet.contrib.onnx.import_model
```

## Import ONNX model into Mxnet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ONNX Model in MXNet

You can download the converted ONNX model from
[here](https://s3.amazonaws.com/onnx-mxnet/examples/super_resolution.onnx).

A pre-trained model in MXNet contains two elements: a symbolic graph, containing the model's network definition, and a binary file containing the model weights. You can import the ONNX model and get the symbol and parameters objects using "import_model" API as shown below:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bulleted points

  • Symbolic graph(with the extension .json) - containing the model's network definition
  • Binary file(with the extension .params) - containing model weights.
    ..


```
# By default, 'input_0' is an input of the imported model.
mod = mx.mod.Module(symbol=sym, data_names=['input_0'], context=mx.cpu(), label_names=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

link to Module API/tutorial page, similarly others where useful

@ThomasDelteil
Copy link
Contributor

I am writing a tutorial on ONNX with MXNet, it would be nice if the docs show an example on how to load an ONNX model in Gluon using a symbolic block.

@anirudhacharya
Copy link
Member Author

@ThomasDelteil Will include it. As discussed on github, we will also eventually have an API for gluon import and that API will have its own documentation and example illustration.

@anirudhacharya
Copy link
Member Author

@aaronmarkham

@anirudhacharya
Copy link
Member Author

This is how the page renders - http://34.227.67.197/api/python/contrib/onnx.html
Please review @aaronmarkham @sandeep-krishnamurthy @nswamy

@anirudhacharya anirudhacharya changed the title Docs page for ONNX module. [MXNET-121] Docs page for ONNX module. Mar 29, 2018

## Overview

[ONNX](https://onnx.ai/) is an open format to represent deep learning models. With ONNX as an intermediate representation, it is easier to move models between state-of-the-art tools and frameworks for training and inference..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra period


[ONNX](https://onnx.ai/) is an open format to represent deep learning models. With ONNX as an intermediate representation, it is easier to move models between state-of-the-art tools and frameworks for training and inference..

The `mxnet.contrib.onnx` package refers to the APIs and interfaces that implements ONNX model format support for Apache MXNet.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implement


The `mxnet.contrib.onnx` package refers to the APIs and interfaces that implements ONNX model format support for Apache MXNet.

With ONNX format support for MXNet, developers can build and train models with PyTorch, CNTK, or Caffe2, and import these models into MXNet to run them for inference and training using MXNet’s highly optimized engine.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplify.
...train models with a variety of deep learning frameworks...
Then list the currently supported frameworks with bullets. (easier to maintain too, when we add more later)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this -
... train models with a variety of deep learning frameworks....
I have linked it to the supported tools page on the ONNX website. That way our page never gets outdated.

```

```eval_rst
.. note:: To use this module developers need to **install ONNX**, which needs protobuf compiler, to be installed separately. Please follow the instructions to install ONNX - https://github.com/onnx/onnx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this installation instructions.

- learn how to load a pre-trained ONNX model file into MXNet.
- run inference in MXNet.

## Pre-requisite
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plural, no dash

- run inference in MXNet.

## Pre-requisite
The code demonstration assumes that the following python packages are installed:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example assumes...

sym, arg, aux = onnx_mxnet.import_model(onnx_model_file)
```

We can now visualize the imported model( graphviz needs to be installed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space before ( not after

mod.set_params(arg_params=arg, aux_params=aux, allow_missing=True, allow_extra=True)
```

Module API's forward method requires Batch of data as input. We will prepare the data in that format and feed it to the forward method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lower case b

Copy link
Contributor

@aaronmarkham aaronmarkham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTG!

Copy link
Contributor

@sandeep-krishnamurthy sandeep-krishnamurthy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for this documentation and tutorial.

@nswamy - Are your requested changes addressed?


The `mxnet.contrib.onnx` package refers to the APIs and interfaces that implement ONNX model format support for Apache MXNet.

With ONNX format support for MXNet, developers can build and train models with a [variety of deep learning frameworks](http://onnx.ai/supported-tools), and import these models into MXNet to run them for inference and training using MXNet’s highly optimized engine.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also for re training and transfer learning usecases right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@sandeep-krishnamurthy sandeep-krishnamurthy merged commit 10c6af4 into apache:master Apr 2, 2018
lanking520 pushed a commit to lanking520/incubator-mxnet that referenced this pull request Apr 2, 2018
* ONNX Documentation

* Fix rendering issues.

* lint issues

* fixing image links

* Fix Aaron's comments

* rerun CI due to unrelated failures.
haojin2 pushed a commit to haojin2/incubator-mxnet that referenced this pull request Apr 2, 2018
* ONNX Documentation

* Fix rendering issues.

* lint issues

* fixing image links

* Fix Aaron's comments

* rerun CI due to unrelated failures.
@anirudhacharya anirudhacharya deleted the docs branch April 16, 2018 18:05
rahul003 pushed a commit to rahul003/mxnet that referenced this pull request Jun 4, 2018
* ONNX Documentation

* Fix rendering issues.

* lint issues

* fixing image links

* Fix Aaron's comments

* rerun CI due to unrelated failures.
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* ONNX Documentation

* Fix rendering issues.

* lint issues

* fixing image links

* Fix Aaron's comments

* rerun CI due to unrelated failures.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants