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

Register Shape Func for Some Operators to Handle Dynamic Shapes #5955

Merged
merged 13 commits into from
Jul 23, 2020

Conversation

lsy643
Copy link
Contributor

@lsy643 lsy643 commented Jun 29, 2020

In order to deal with dynamic shapes occurs when compiling a object detection model like Faster Rcnn, many operators need shape functions for ManifestAlloc pass.

Several shape functions have been created or registered:

  1. floor
  2. log
  3. crop_and_resize
  4. mirror_pad

lsy643 added 2 commits June 29, 2020 15:25
Register the shape function for `floor` operator. Otherwise, a bug will happen when input of floor is any.
@lsy643 lsy643 changed the title Register Shape Func for Floor Operator Register Shape Func for floor and log Operators Jun 29, 2020
@lsy643 lsy643 changed the title Register Shape Func for floor and log Operators Register Shape Func for Some Operators to Handle Dynamic Shapes Jun 30, 2020
Copy link
Member

@icemelon icemelon left a comment

Choose a reason for hiding this comment

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

Could you add test cases for crop_and_resize and mirror_pad in tests/python/relay/test_any.py?

@icemelon icemelon self-assigned this Jul 10, 2020
@lsy643
Copy link
Contributor Author

lsy643 commented Jul 13, 2020

@icemelon9 I have added test case for crop_and_resize and mirror_pad in tests/python/relay/test_any.py.

And there is something I may need to illustrate further. According to the MirrorPadRel function, mirror_pad only accepts static input shape. However, mirror_pad and another operator with dynamic input shape may get fused into a same function, and then the shape function of 'mirror_pad' is necessary.

@lsy643 lsy643 requested a review from icemelon July 13, 2020 11:28
@lsy643 lsy643 requested a review from icemelon July 15, 2020 01:35
python/tvm/relay/op/image/_image.py Show resolved Hide resolved
tests/python/relay/test_any.py Outdated Show resolved Hide resolved
Copy link
Member

@icemelon icemelon left a comment

Choose a reason for hiding this comment

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

LGTM. just two minor comments.

tests/python/relay/test_any.py Outdated Show resolved Hide resolved
tests/python/relay/test_any.py Outdated Show resolved Hide resolved
@icemelon icemelon merged commit fe76196 into apache:master Jul 23, 2020
@icemelon
Copy link
Member

Thanks @lsy643

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Aug 26, 2020
…he#5955)

* Register Shape Func for Floor Operator

Register the shape function for `floor` operator. Otherwise, a bug will happen when input of floor is any.

* Register shape func for log

* add shape function for crop_and_size

* change import location

* add mirror_pad shape function

* add test cases for crop_and_resize and mirror_pad shape funcs

* support different layout

* fix pylint error

* fix pylint error

* add test for nchw layout

* block nchw test

* test for nchw

* use tvm.testing.assert_allclose instead

Co-authored-by: lisiyuan <lisiyuan@nucflow>
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Aug 26, 2020
…he#5955)

* Register Shape Func for Floor Operator

Register the shape function for `floor` operator. Otherwise, a bug will happen when input of floor is any.

* Register shape func for log

* add shape function for crop_and_size

* change import location

* add mirror_pad shape function

* add test cases for crop_and_resize and mirror_pad shape funcs

* support different layout

* fix pylint error

* fix pylint error

* add test for nchw layout

* block nchw test

* test for nchw

* use tvm.testing.assert_allclose instead

Co-authored-by: lisiyuan <lisiyuan@nucflow>
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Sep 2, 2020
…he#5955)

* Register Shape Func for Floor Operator

Register the shape function for `floor` operator. Otherwise, a bug will happen when input of floor is any.

* Register shape func for log

* add shape function for crop_and_size

* change import location

* add mirror_pad shape function

* add test cases for crop_and_resize and mirror_pad shape funcs

* support different layout

* fix pylint error

* fix pylint error

* add test for nchw layout

* block nchw test

* test for nchw

* use tvm.testing.assert_allclose instead

Co-authored-by: lisiyuan <lisiyuan@nucflow>
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Sep 3, 2020
…he#5955)

* Register Shape Func for Floor Operator

Register the shape function for `floor` operator. Otherwise, a bug will happen when input of floor is any.

* Register shape func for log

* add shape function for crop_and_size

* change import location

* add mirror_pad shape function

* add test cases for crop_and_resize and mirror_pad shape funcs

* support different layout

* fix pylint error

* fix pylint error

* add test for nchw layout

* block nchw test

* test for nchw

* use tvm.testing.assert_allclose instead

Co-authored-by: lisiyuan <lisiyuan@nucflow>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants