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

ONNX import/export: Upsampling #15994

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vandanavk
Copy link
Contributor

@vandanavk vandanavk commented Aug 24, 2019

Description

Support ONNX import/export of Upsampling operator.

Fixes #12851
Depends on #15811

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • The PR title starts with [MXNET-$JIRA_ID], where $JIRA_ID refers to the relevant JIRA issue created (except PRs with tiny changes)
  • 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
  • Check the API doc at http://mxnet-ci-doc.s3-accelerate.dualstack.amazonaws.com/PR-$PR_ID/$BUILD_ID/index.html
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Add ONNX importer/exporter, relevant test

Comments

  • This depends on another PR which adds support for tuple of scales in upsampling operator. Ack: @benhe2011 for testing this PR and updating upsampling operator.

@vandanavk vandanavk requested a review from szha as a code owner August 24, 2019 19:13
@vandanavk
Copy link
Contributor Author

@mxnet-label-bot add [ONNX, pr-awaiting-review]

@marcoabreu marcoabreu added ONNX pr-awaiting-review PR is waiting for code review labels Aug 24, 2019
@anirudhacharya
Copy link
Member

Depends on #15811

if it depends on the above PR, which is not merged, then how are the tests passing?

@kreid415
Copy link

Any update on this PR?

@jeremiedb
Copy link
Contributor

jeremiedb commented Nov 22, 2019

@oeway
Copy link

oeway commented Feb 5, 2020

Thanks for working on this, I am interested in exporting a model to ONNX with Upsampling (nearest). Currently it complains AttributeError: No conversion function registered for op type UpSampling yet..

It would really great if this PR can move on and get merged.

@oriori
Copy link

oriori commented Feb 11, 2020

I'd like to reiterate what @oeway said by first thanking you for working on this. Also, please note there is no way to redesign a model around this problem as alternatives such as repeat and deconvolution also cause the export to fail. This problem has been lingering for quite some time. Maybe @szha can assign this to someone.
Thank you

@anirudhacharya
Copy link
Member

@jeremiedb @oeway @oriori I have asked( offline) @vandanavk to rebase the PR. Once she does, I will review/merge the PR.

@szha
Copy link
Member

szha commented May 24, 2020

Pinging @vandanavk. BTW, since master branch is for 2.0 development and Upsampling op will be reorganized elsewhere, based on the change, I recommend switching the target branch to 1.x instead.

cc @sandeep-krishnamurthy on ONNX op coverage


@mx_op.register("UpSampling")
def convert_upsample(node, **kwargs):
"""Map MXNet's UpSampling operator attributes to onnx's Upsample operator
Copy link

@dungmn dungmn Mar 19, 2021

Choose a reason for hiding this comment

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

missing the end """ at line 2086?

@MengboZ
Copy link

MengboZ commented Dec 8, 2021

@vandanavk @anirudhacharya @kreid415 @jeremiedb @oeway Sorry to bother you again, I want to import ONNX model from MXnet, I changed my corresponding file according to Files changed, another error occurred after I changed:

Traceback (most recent call last):
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/amax/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/lib/python/debugpy/__main__.py", line 45, in <module>
    cli.main()
  File "/home/amax/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 444, in main
    run()
  File "/home/amax/.vscode-server/extensions/ms-python.python-2021.11.1422169775/pythonFiles/lib/python/debugpy/../debugpy/server/cli.py", line 285, in run_file
    runpy.run_path(target_as_str, run_name=compat.force_str("__main__"))
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/runpy.py", line 265, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/amax/zmb/segnet_tvm/net_random/to_onnx.py", line 69, in <module>
    load_onnx_mxnet()
  File "/home/amax/zmb/segnet_tvm/net_random/to_onnx.py", line 62, in load_onnx_mxnet
    sym, arg = onnx_mxnet.import_model(onnx_path)
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/import_model.py", line 59, in import_model
    sym, arg_params, aux_params = graph.from_onnx(model_proto.graph)
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/import_onnx.py", line 115, in from_onnx
    mxnet_sym = self._convert_operator(node_name, op_name, onnx_attr, inputs)
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/import_onnx.py", line 61, in _convert_operator
    op_name, new_attrs, inputs = convert_map[op_name](attrs, inputs, self)
  File "/home/amax/anaconda3/envs/tvm-build/lib/python3.8/site-packages/mxnet/contrib/onnx/onnx2mx/_op_translations.py", line 806, in upsampling
    scale = tuple(new_attrs.get('scale'))[2:]
TypeError: 'NoneType' object is not iterable

Since I'm new to these, I don't quite understand what the error is. By the way, can Upsample be imported into MXNET so far? Has this been achieved? Thank you and look forward to your reply.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ONNX pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error while converting onnx model to Mxnet