Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spec and shape inference for Unsqueeze op #2347

Merged
merged 11 commits into from Sep 24, 2019

Conversation

hariharans29
Copy link
Contributor

  1. Unsqueeze op is unclear on how it deals with values in axes and what are the acceptable values for axes

  2. Fix shape inference logic. In current state, it cannot handle negative axes properly (the way it is intended to)

@hariharans29 hariharans29 requested review from a team as code owners September 24, 2019 01:41
@hariharans29
Copy link
Contributor Author

CC: @wschin @gramalingam

[])
self._assert_inferred(graph, [make_tensor_value_info('y', TensorProto.FLOAT, (1, 3, 4, 5, 1))])

def test_unsqueeze_negative_axes(self): # type: () -> None
Copy link
Contributor Author

Choose a reason for hiding this comment

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

won't work with existing logic.

@hariharans29 hariharans29 reopened this Sep 24, 2019
@wschin wschin closed this Sep 24, 2019
@wschin wschin reopened this Sep 24, 2019
Copy link
Contributor

@spandantiwari spandantiwari left a comment

Choose a reason for hiding this comment

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

LGTM. A clarifying comment about the order of axes in axes would be good to have.

Given an input tensor (`data`) of shape [3, 4, 5], then
Unsqueeze(data, axes=[0, 4]) outputs a tensor (`expanded`) containing same data as `data` but with shape [1, 3, 4, 5, 1].

The attribute `axes` should not contain any duplicate entries. It is an error if it contains duplicates.
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 for mentioning about duplicate entries.

onnx/defs/tensor/defs.cc Show resolved Hide resolved
@wschin
Copy link
Contributor

wschin commented Sep 24, 2019

Do we have tests for unsorted cases?

@hariharans29
Copy link
Contributor Author

Do we have tests for unsorted cases?

I will add shape inference test for now.

@hariharans29
Copy link
Contributor Author

@spandantiwari @wschin - added backend test for unsorted axes too

@wschin wschin merged commit 2873fea into onnx:master Sep 24, 2019
wschin pushed a commit to wschin/onnx that referenced this pull request Sep 24, 2019
* Fix spec for Unsqueeze

* Update Changelog.md

* Refine doc

* Refine

* PR comments

* Update Changelog.md

* Update shape inference test file
kevinch-nv pushed a commit that referenced this pull request Sep 25, 2019
* Relax IF's shape inference rule (#2345)

* Relax If's shape inference rule

* Make shape inference tests ok and move code to the right place

* Add document changes

* Update onnx/defs/controlflow/defs.cc

* Update onnx/defs/controlflow/defs.cc

* Address comments

* Address comments

* Address comments

* Fix shape inference test

* Disable a type check

* Address a comment

* Update defs.cc

* Update Changelog.md

* Update Operators.md

* Bump NMS version for avoiding regression in existing models (#2348)

* Bump NMS version for avoiding regression in existing models

* Bring old logic back

* Fix spec and shape inference for Unsqueeze op (#2347)

* Fix spec for Unsqueeze

* Update Changelog.md

* Refine doc

* Refine

* PR comments

* Update Changelog.md

* Update shape inference test file
jcwchen pushed a commit to jcwchen/onnx that referenced this pull request Sep 23, 2020
* Fix spec for Unsqueeze

* Update Changelog.md

* Refine doc

* Refine

* PR comments

* Update Changelog.md

* Update shape inference test file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants