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

[ONNX] Added Unsqueeze operator import support #11106

Merged
merged 2 commits into from
Jun 4, 2018

Conversation

rajanksin
Copy link
Contributor

@rajanksin rajanksin commented May 31, 2018

Description

ONNX Unsqueeze op maps to expand dims. Added the support.

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

  • Unsqueeze op support
  • Added operator test.

Comments

  • If this change is a backward incompatible change, why must this change be made.
  • Interesting edge cases to note here

@anirudhacharya @anirudh2290 @lupesko

@rajanksin rajanksin requested a review from szha as a code owner May 31, 2018 00:12
# MXNet can only add one axis at a time.
mxnet_op = inputs[0]
for axis in attrs["axes"]:
mxnet_op = symbol.expand_dims(mxnet_op, axis=axis)
Copy link
Member

Choose a reason for hiding this comment

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

can axes have repeats ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there is no restriction on repeats.the logic would still work. I tested it , it works fine.

Copy link
Member

Choose a reason for hiding this comment

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

What is the expectation of how unsqueeze should work with repeats ? if unsqueeze called with attrs(1, 1) and tensor of shape(1, 2) should it return a tensor of shape (1,1,1,2) or (1,1,2) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

return tensor shape (1,1,1,2).

Copy link
Member

Choose a reason for hiding this comment

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

okay!

@@ -106,6 +106,16 @@ def test_squeeze():
output = mxnet_backend.run_node(node_def, [input1])[0]
npt.assert_almost_equal(output, np.squeeze(input1, axis=[1, 3]))

@with_seed()
Copy link
Member

Choose a reason for hiding this comment

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

can we not use the backend tests added to the fw here: https://github.com/onnx/onnx/pull/497/files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, i can enable that. I will wait for #10605 to merge and then add appropriately ( as it modifies test files)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Enabled ONNX backend test for Unsqueeze

@anirudh2290 anirudh2290 merged commit 106b040 into apache:master Jun 4, 2018
zheng-da pushed a commit to zheng-da/incubator-mxnet that referenced this pull request Jun 28, 2018
* Unsqueeze operator support

* Enabled unsqeeze test in ONNX test framework
XinYao1994 pushed a commit to XinYao1994/incubator-mxnet that referenced this pull request Aug 29, 2018
* Unsqueeze operator support

* Enabled unsqeeze test in ONNX test framework
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