-
Notifications
You must be signed in to change notification settings - Fork 356
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
Extending @uni19's work on support dynamic shape input and scale_factor in interpolate layer #295
Conversation
Signed-off-by: uni19 <[email protected]>
…into uni19-dynamic_interpolate
suite This commit adds onto the work done by @uni19 and adds support for the two variants of upsample ops. It also radically simplifies the tests for this component. Known issues: Right now both for scales and scale factors align corners being true causes errors Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
… edge case This commit adds support in some cases for the edge case when handling torch.nn.functional.interpolate where the user is doing some form of linear upsampling and uses scale factor to calculate the new tensor size at runtime and they set align corners to true (as of PyTorch 1.5 this is no longer the default behavior). This commit adds support for this case when users chose to construct static input size engines via the interpolate plugin which will run the function from ATen on CPU. In the case of dynamic input shapes with these 3 conditions the compilation will terminate with an error. The ultimate solution will be to find the root cause of the descripancy between PyTorch and TensorRT. Barring that we will need to use the dimension calculation primatives for TensorRT plugins. However, there is a limitation where static values in the computation cannot be floats which PyTorch scale factors are. Therefore it doesn't seem possible currently to support this usecase. Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to Python style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to C++ style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to Python style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code conforms to C++ style guidelines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Verified testcases on my local with TRT 7.2.2.3
Description
This PR includes the changes in #258, does some refactoring of the test suite for interpolate and should expand coverage of the interpolate converter for the two variants of each of the currently supported resize functions (self, and vec). It should mean that we support interpolate for nearest and linear variants for all cases except when users use a type of linear upsampling, use scale factor for setting the size and set
align_corners
to true. It seems like @uni19 found that TensorRT and PyTorch have different behavior in this case. I will check with the TRT team to see if they have observed this. Hopefully it is not a massive issue as PyTorch since 1.5 has switched toalign_corners
being false by default. As a stop gap this PR extends the interpolate plugin to handle this case, however it can only do so for static TRT engines. Currently the build time dimension calculation can only be done withint
s where as scale factors for PyTorch arefloat
s. Therefore in the case of dynamic engine for a model using [Bi/Tri]Linear interpolate with scale factor andalign_corners
=True, TRTorch will error out. Hopefully this is niche enough of a use case to not cause issues until we get a response from TensorRT.Fixes #290
Type of change
Please delete options that are not relevant and/or add your own.
Checklist: