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

[MXNET-344] [ONNX-MXNet] Add new Operator Translations for ONNX import module #11140

Merged
merged 24 commits into from
Jun 12, 2018

Conversation

anirudhacharya
Copy link
Member

@anirudhacharya anirudhacharya commented Jun 4, 2018

Description

Add translations for the following operators.

  • Greater
  • Softplus
  • InstanceNormalization
  • Clip
  • Less
  • MaxRoiPool
  • Equal
  • LogSoftmax
  • Squeeze
  • ReduceLogSum
  • ReduceLogSumExp
  • ReduceSumSquare
  • Softsign
  • Not
  • Or
  • And
  • XOR

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 https://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 new operator translations

Comments

Anirudh Acharya and others added 20 commits April 11, 2018 18:44
gluonImport

# Conflicts:
#	python/mxnet/contrib/onnx/__init__.py
#	python/mxnet/contrib/onnx/_import/import_model.py
#	python/mxnet/contrib/onnx/_import/import_onnx.py
newOps

# Conflicts:
#	python/mxnet/contrib/onnx/_import/import_to_gluon.py
#	python/mxnet/contrib/onnx/_import/op_translations.py
#	tests/python-pytest/onnx/import/gluon_backend.py
#	tests/python-pytest/onnx/import/gluon_backend_test.py
#	tests/python-pytest/onnx/import/mxnet_backend.py
#	tests/python-pytest/onnx/import/mxnet_backend_test.py
#	tests/python-pytest/onnx/import/test_cases.py
@anirudhacharya anirudhacharya requested a review from szha as a code owner June 4, 2018 18:52
@anirudhacharya anirudhacharya changed the title Add new Operator Translations for ONNX import module [ONNX-MXNet] [WIP} Add new Operator Translations for ONNX import module Jun 4, 2018
@anirudhacharya anirudhacharya changed the title [ONNX-MXNet] [WIP} Add new Operator Translations for ONNX import module [MXNET-344] [ONNX-MXNet] Add new Operator Translations for ONNX import module Jun 12, 2018
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.

Thanks @anirudhacharya for your contributions!
Overall looks good to me.
2 questions below and we are ready to go.

if 'a_max' not in new_attrs:
new_attrs = translation_utils._add_extra_attributes(new_attrs, {'a_max' : np.inf})
if 'a_min' not in new_attrs:
new_attrs = translation_utils._add_extra_attributes(new_attrs, {'a_min' : -np.inf})
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use np.ninf? I think that is float, please check once.

Copy link
Member Author

Choose a reason for hiding this comment

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

def reduce_log_sum(attrs, inputs, proto_obj):
"""Reduce the array along a given axis by log sum value"""
keep_dims = True if 'keepdims' not in attrs else attrs.get('keepdims')
sum_op = symbol.sum(inputs[0], axis=attrs.get('axes'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why inputs[0]?

Copy link
Member Author

Choose a reason for hiding this comment

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

ReduceLogSum op takes has input tensor - https://github.com/onnx/onnx/blob/master/docs/Operators.md#ReduceLogSum. And while translating this ONNX operator into MXNet, we are splitting the reduceLogSum op to sum over a given axis and then log operator.

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

@sandeep-krishnamurthy sandeep-krishnamurthy merged commit 4818103 into apache:master Jun 12, 2018
@anirudhacharya anirudhacharya deleted the newOps branch June 12, 2018 20:39
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
…t module (apache#11140)

* gluon import

* gluon tests

* shape issues.

* remove the dim_change list

* onnx backend tests

* changes to match onnx op set version 7

* fix

* lint fix

* add new folder

* fix

* fix

* rename test file

* tile topk clip

* more ops

* fix

* fix
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
…t module (apache#11140)

* gluon import

* gluon tests

* shape issues.

* remove the dim_change list

* onnx backend tests

* changes to match onnx op set version 7

* fix

* lint fix

* add new folder

* fix

* fix

* rename test file

* tile topk clip

* more ops

* fix

* fix
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.

2 participants