Skip to content

Fix spec and shape inference for Unsqueeze op#2347

Merged
wschin merged 11 commits intoonnx:masterfrom
hariharans29:fixUnsqueeze
Sep 24, 2019
Merged

Fix spec and shape inference for Unsqueeze op#2347
wschin merged 11 commits intoonnx:masterfrom
hariharans29:fixUnsqueeze

Conversation

@hariharans29
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread onnx/defs/tensor/defs.cc
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
Copy Markdown
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.

Comment thread onnx/defs/tensor/defs.cc
@wschin
Copy link
Copy Markdown
Collaborator

wschin commented Sep 24, 2019

Do we have tests for unsorted cases?

@hariharans29
Copy link
Copy Markdown
Contributor Author

Do we have tests for unsorted cases?

I will add shape inference test for now.

@hariharans29
Copy link
Copy Markdown
Contributor Author

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

Comment thread onnx/backend/test/case/node/unsqueeze.py
@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.

3 participants