-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add torch_meshgrid_ij wrapper due to PyTorch change #2044
Add torch_meshgrid_ij wrapper due to PyTorch change #2044
Conversation
I have updated the PR based on the discussion here: |
Hi, thanks for your contribution. We can append this function at https://github.com/open-mmlab/mmcv/blob/master/mmcv/utils/__init__.py#L56. Besides, it would be better to add unit tests for this function at https://github.com/open-mmlab/mmcv/tree/master/tests/test_utils/test_torch_ops.py. |
Hi, in the process of trying to help you guys with this |
Thanks for your contributions. We will commit to this PR. |
Motivation
PyTorch is in the process of changing the behaviour of
torch.meshgrid
, and this results in a warning when using this method without anindexing
argument as of PyTorch 1.10. The problem is that prior to PyTorch 1.10 these is no such argument, and thus for compatibility reasons it can't just be added. PyTorch 1.8.2 is an LTS release, so this issue will likely not go away any time soon, and eventually PyTorch will make a breaking change that changes the default behaviour of the method when called without an indexing argument:https://pytorch.org/docs/stable/generated/torch.meshgrid.html
pytorch/pytorch#50276
While mmcv has no calls to
torch.meshgrid
, many other repos do (this is not an exhaustive list):open-mmlab/mmpretrain#860
open-mmlab/mmdetection#8090
open-mmlab/mmtracking#577
open-mmlab/mmpose#1402
Thus, it would be best if mmcv could store a wrapper for
torch_meshgrid_ij
that deals with this difficulty, so that eventually all the other repos can just use the wrapper in mmcv instead of all defining their own or otherwise dealing with the issue.Modification
This PR adds a suitable
torch_meshgrid_ij
wrapper.Checklist
Before PR:
After PR: