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

[DYNAMIC] Add Dynamic reshape to a dynamic namespace and add DynamicToStatic Pass #5826

Merged
merged 17 commits into from
Jul 1, 2020

Conversation

mbrookhart
Copy link
Contributor

@mbrookhart
Copy link
Contributor Author

Hitting an issue with dynamic shapes on GPU with the VM.

data.shape = (2,3,4), newshape = (-3,-2), result.shape = (6,4)

Special values -2 and -4 from the standard reshape op would introduce dynamic rank
in this op. Thus, they are not permitted.
Copy link
Contributor

@lixiaoquan lixiaoquan Jun 19, 2020

Choose a reason for hiding this comment

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

Current code allows -2 and -4 as constant value. Should frontend check it like

if newshape_inferable() and newshape == (-2) or newshape == (-4):
    return _op.reshape()
else:
    return _op.dynamic.reshape()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The Input is a dynamic Expression, I can't check it at graph construction time.

@icemelon
Copy link
Member

Shall we just call the namespace dyn? I'm okay with dynamic, but just feel it is a bit long.

@tqchen
Copy link
Member

tqchen commented Jun 19, 2020

I agree with @icemelon9 perhaps dyn is a better name here.

@mbrookhart
Copy link
Contributor Author

👍 Happy to shorten it.

@mbrookhart mbrookhart force-pushed the mbrookhart/dynamic_reshape branch from 9453400 to e31c03c Compare June 22, 2020 16:32
@icemelon
Copy link
Member

In fact, I have another thought on this. Should we make the dynamic ops as the default ones whereas having static ops as special cases for better optimization?

@jroesch
Copy link
Member

jroesch commented Jun 23, 2020

@icemelon9 That was my initial suggestion, I think we reached consensus between TQ, Matt and I that we would introduce dynamic and slowly migrate stuff to use them, then introduce static migrate everything to that, and then finally remove the dynamic prefix inorder to ensure a smooth migration without confusion.

@tqchen
Copy link
Member

tqchen commented Jun 24, 2020

cc @kevinthesun @lixiaoquan given that we agreed on the new convention, it would be great if we can also migrate some of the existing dynamic(symbolic) effort towards this direction

@tqchen
Copy link
Member

tqchen commented Jun 25, 2020

@icemelon
Copy link
Member

@mbrookhart Since we separate the static and dynamic reshape in this pr, we should remove the Optional in the ReshapeAttrs correspondingly.

@mbrookhart mbrookhart force-pushed the mbrookhart/dynamic_reshape branch from 643b115 to b423200 Compare June 26, 2020 19:06
@mbrookhart
Copy link
Contributor Author

@icemelon9 @lixiaoquan Per Haichen's request, I removed the dynamic option from the standard reshape and changed the places that used it to use the new purely dynamic op. This touches many more files, could you take another look?

@mbrookhart mbrookhart force-pushed the mbrookhart/dynamic_reshape branch from b423200 to f87bbee Compare June 29, 2020 16:34
@mbrookhart mbrookhart force-pushed the mbrookhart/dynamic_reshape branch from 4737479 to 2e2c963 Compare June 30, 2020 16:20
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 some minor comments.

src/relay/analysis/util.cc Outdated Show resolved Hide resolved
python/tvm/relay/op/_tensor_grad.py Show resolved Hide resolved
src/relay/op/dyn/tensor/transform.cc Outdated Show resolved Hide resolved
src/relay/op/tensor/transform.h Outdated Show resolved Hide resolved
@icemelon icemelon merged commit b979bf6 into apache:master Jul 1, 2020
@icemelon
Copy link
Member

icemelon commented Jul 1, 2020

trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jul 14, 2020
…oStatic Pass (apache#5826)

* Dynamic reshape passing tests

* Add Dynamic to Static Pass

* rename test file to prevent pytest conflicts

* fix clang build

* add nested dynamic shape test

* remove cuda tests until VM supports dynamic shapes

* rename namespace from dynamic to dyn

* fix lint

* fix lint again

* Remove incorrect doc strings

* remove dynamic behavior from standard reshape

* fix some tests

* merge dynamic and static interfaces in python

* fix missing import

* missed a reference to relay.dyn.reshape

* fix vta example

* respond to review comments
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jul 14, 2020
…oStatic Pass (apache#5826)

* Dynamic reshape passing tests

* Add Dynamic to Static Pass

* rename test file to prevent pytest conflicts

* fix clang build

* add nested dynamic shape test

* remove cuda tests until VM supports dynamic shapes

* rename namespace from dynamic to dyn

* fix lint

* fix lint again

* Remove incorrect doc strings

* remove dynamic behavior from standard reshape

* fix some tests

* merge dynamic and static interfaces in python

* fix missing import

* missed a reference to relay.dyn.reshape

* fix vta example

* respond to review comments
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.

6 participants