Skip to content

Conversation

@jroesch
Copy link
Member

@jroesch jroesch commented Nov 20, 2018

Add code which converts and NNVM model to a Relay program.

@slyubomirsky
Copy link
Contributor

Very good idea, lets us get lots of Relay test cases for free

@jroesch jroesch changed the title [RELAY][WIP] Port from_nnvm to NNVM as to_relay [RELAY] Port from_nnvm to NNVM as to_relay Nov 26, 2018
@jroesch
Copy link
Member Author

jroesch commented Nov 26, 2018

@ZihengJiang @tqchen review would be good now, after rebasing I fixed a few bugs, tests are green, just need to fix linting and clean up a few things.

@jroesch
Copy link
Member Author

jroesch commented Nov 27, 2018

@siju-samuel, @eqy could you review this @tqchen said it would be good to have you do review.


if op_name == "null":
v = var(node_name, shape=oshape, dtype=odtype)
params.append(v)
Copy link
Member

Choose a reason for hiding this comment

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

This need to be updated to support the multiple output cases, consider directly reuse logic(we can refactor the function to take convert_map as argument) https://github.com/dmlc/tvm/blob/master/python/tvm/relay/frontend/mxnet.py#L469

Copy link
Member Author

Choose a reason for hiding this comment

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

There is code below to handle multiple outputs, it will generate a tuple of all the outputs unless I'm missing something.

Copy link
Member

Choose a reason for hiding this comment

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

I see that now, the two code handled it differently. In the mxnet converter code relay_map is asked to always record a list, tuple, or TuppleWrapper, and when we get the child we always fetch the corresponding index. This is going to be helpful for cases when we need post proc for multiple outputs(which can directly return a list).

The reason that I thought it only works with single output is due to the fact that when you get oshape, you only get output 0(instead of a list of all of them), so for functions like split, you only get the first output

return op.divide(left, right)


def _to_rshift(children, attrs, odtype):
Copy link
Member

Choose a reason for hiding this comment

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

consider summarizing function as _rbinop_scalar(new_op) as in https://github.com/dmlc/tvm/blob/master/python/tvm/relay/frontend/mxnet.py#L130

return dense


def _to_relu(children, attrs, odtype):
Copy link
Member

Choose a reason for hiding this comment

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

@eqy
Copy link
Contributor

eqy commented Nov 27, 2018

This is a little random but I noticed that we are using fancy python3.6 string features here, did we already declare that we are dropping support for python3.5?

@tqchen
Copy link
Member

tqchen commented Nov 27, 2018

We do need to keep it compatible by not using the python3.6 features here

def check_model(sym, shapes, dtypes):
net = nnvm.graph.create(sym)
graph_json, mod, params = nnvm.compiler.build(net, 'llvm', shape=shapes, dtype=dtypes)
relay_model = to_relay.from_nnvm(net, shapes, dtypes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I missing an import here? When I try to run this it can't find from_nnvm in to_relay.

@jroesch jroesch force-pushed the nnvm_to_relay branch 4 times, most recently from 36b75b5 to 9fe2e8f Compare December 3, 2018 20:54
Repair imports

First test passes

Fix bug in axes passing

Add implementations for upsampling and pad

Add support for bias with conv ops

Rebase fixup

Borrow the reshape changes while waiting on apache#2159

Debugging tests

Repair after rebase

Refactor to use common functionality

Fix helper func

Remove final eval

Remove some debuggin

Remove unecessary ws change

Fix multiple outputs

Tests pass

Enable all tests

Rebase repair

Fix last test case

Fix last test case

All tests but RNNs pass

Fix tests

Remove final eval

Reformat

Fix bugs in MxNet

Fix 3.5 support in Relay, and rename

Factor common functionality into one file

Apply most of code review

Fix linting

Fix NNVM linting

Fix test error

Fix MLP test

Fix linting error

One more linting issue

Clean up diff and fix bugs

Retrigger

disable MLP test

Retrigger

Retrigger

Roll back NNVM change

Retrigger

Retrigger

Retrigger
@tqchen tqchen merged commit 58398d3 into apache:master Dec 4, 2018
FrozenGene pushed a commit to FrozenGene/tvm that referenced this pull request Dec 27, 2018
wweic pushed a commit to neo-ai/tvm that referenced this pull request Feb 20, 2019
wweic pushed a commit to neo-ai/tvm that referenced this pull request Feb 20, 2019
@jroesch jroesch deleted the nnvm_to_relay branch February 4, 2021 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants