Skip to content

fix interpolate dynamic input #3

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

huliang2016
Copy link

#2

@grimoire
Copy link
Owner

Hi
Thanks for the bug report. The dynamic shape support of interpolate is a little bit ... complex.
I warp the Tensor.shape[i] to a IntWarper in size.py to trace the shape data. as for interpolate, if the size contain any IntWarper, is_shape_tensor flag will be set. That means if your model is:

        xh, xw = x.shape[-2] * 2, x.shape[-1] * 2
        x = F.interpolate(x, size=(xh, xw), mode="nearest")

The convert should give you right anwser.
But you have cast it back to python int. That IntWarper can not trace the shape any more. A const value will be used as interpolate shape.
Use scales instead of shape might not be a good idea. because the shape could be:

xh, xw = x.shape[-2]+10, x.shape[-1]-10

I am trying to do something about int cast. If you have any idea. Please share it with me.

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.

2 participants