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

[v1.x] Update onnx support to work with onnx 1.7.0 with most CV models #19017

Merged
merged 35 commits into from
Sep 11, 2020

Conversation

josephevans
Copy link
Contributor

@josephevans josephevans commented Aug 26, 2020

Description

This PR improves MXNet support for onnx import and export for newer onnx versions (including the latest, 1.7.0).

The goal of this PR is to allow exporting of the most common CV models used and verify inference with the latest onnxruntime (1.4.0).

With newer onnx opset versions, the attributes for some operators have been changed to inputs, so most of the work in the two _op_translations.py files relates to converting between attributes and inputs. Updated operator translations between MXNet and onnx as follows:

Export operators:

Import operators:

  • Dropout
  • Pad
  • Slice
  • Clip
  • Topk

This PR also changes the import and export code to pass an “opset_version” variable which defaults to the latest version supported by the installed onnx module. This variable is used to determine what format to use for onnx conversions.

This PR also cherry-picks the following PRs from the master branch:

This PR also updates the CI environments to install the latest version of onnx (1.7.0) and onnxruntime (1.4.0) for testing model export from mxnet and inference using onnxruntime.

All onnx unit tests are passing. An additional onnx test has been added in tests/python-pytest/onnx/test_onnxruntime.py which tests the following models (from gluoncv model zoo) for export and inference in onnxruntime:

  • mobilenet1.0
  • mobilenet0.75
  • mobilenet0.5
  • mobilenet0.25
  • mobilenetv2_1.0
  • mobilenetv2_0.75
  • mobilenetv2_0.5
  • mobilenetv2_0.25
  • resnet18_v1
  • resnet18_v2
  • resnet34_v1
  • resnet34_v2
  • resnet50_v1
  • resnet50_v2
  • resnet101_v1
  • resnet101_v2
  • resnet152_v1
  • resnet152_v2
  • squeezenet1.0
  • squeezenet1.1
  • vgg11
  • vgg11_bn
  • vgg13
  • vgg13_bn
  • vgg16
  • vgg16_bn
  • vgg19
  • vgg19_bn

There are still some operators that need to be updated to support the latest opset versions.

@josephevans josephevans requested a review from szha as a code owner August 26, 2020 15:58
@mxnet-bot
Copy link

Hey @josephevans , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:

  • To trigger all jobs: @mxnet-bot run ci [all]
  • To trigger specific jobs: @mxnet-bot run ci [job1, job2]

CI supported jobs: [centos-cpu, windows-cpu, edge, miscellaneous, unix-cpu, sanity, website, unix-gpu, centos-gpu, clang, windows-gpu]


Note:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.

@josephevans josephevans changed the title [WIP] [v1.x] Update Dropout operator to work with latest ONNX versions (including 1.7) [WIP] [v1.x] Update export functions for operators to work with latest ONNX versions (including 1.7) Aug 27, 2020
@josephevans josephevans changed the title [WIP] [v1.x] Update export functions for operators to work with latest ONNX versions (including 1.7) [v1.x] Update onnx support to work with onnx 1.7.0 Sep 3, 2020
@josephevans josephevans changed the title [v1.x] Update onnx support to work with onnx 1.7.0 [v1.x] Update onnx support to work with onnx 1.7.0 with most CV operators Sep 3, 2020
@josephevans josephevans changed the title [v1.x] Update onnx support to work with onnx 1.7.0 with most CV operators [v1.x] Update onnx support to work with onnx 1.7.0 with most CV models Sep 3, 2020
Copy link
Contributor

@vandanavk vandanavk left a comment

Choose a reason for hiding this comment

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

@sandeep-krishnamurthy
Copy link
Contributor

@Kh4L for review please. Thank you.

Copy link
Contributor

@Kh4L Kh4L 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 backporting these PRs!

@josephevans
Copy link
Contributor Author

@vandanavk Refactored based on your review, could you please approve? thanks,

@samskalicky samskalicky merged commit b888d3c into apache:v1.x Sep 11, 2020
@leezu
Copy link
Contributor

leezu commented Oct 8, 2020

@josephevans what's the status of adding the PR to the master branch?

cc @sandeep-krishnamurthy

leezu pushed a commit to leezu/mxnet that referenced this pull request Oct 8, 2020
Forward port of apache#19017

Co-authored-by: Joe Evans <[email protected]>
@sandeep-krishnamurthy
Copy link
Contributor

Thanks for bringing it up. It should be on 1.X and Joe had plans for the same. @josephevans

josephevans added a commit to josephevans/mxnet that referenced this pull request Nov 20, 2020
Forward port of apache#19017

Co-authored-by: Joe Evans <[email protected]>
josephevans added a commit to josephevans/mxnet that referenced this pull request Nov 23, 2020
Forward port of apache#19017

Co-authored-by: Joe Evans <[email protected]>
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.

8 participants