Use round-to-negative division when computing output sizes for convolutions involving striding and dilation.#9640
Use round-to-negative division when computing output sizes for convolutions involving striding and dilation.#9640resistor wants to merge 1 commit intopytorch:masterfrom
Conversation
|
Thanks! This is great! Do you want to fix the |
|
I think we also want to apply a similar patch to In [1]: import torch
In [2]: conv = torch.nn.Conv2d(1, 1, kernel_size=3, dilation=2, stride=2).cuda()
In [3]: tensor = torch.empty(1, 1, 4, 4).cuda()
In [4]: conv(tensor).shape
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-4-c6df65b7b5a7> in <module>()
----> 1 conv(tensor).shape
~/github/pytorch/torch/nn/modules/module.py in __call__(self, *input, **kwargs)
475 result = self._slow_forward(*input, **kwargs)
476 else:
--> 477 result = self.forward(*input, **kwargs)
478 for hook in self._forward_hooks.values():
479 hook_result = hook(self, input, result)
~/github/pytorch/torch/nn/modules/conv.py in forward(self, input)
299 def forward(self, input):
300 return F.conv2d(input, self.weight, self.bias, self.stride,
--> 301 self.padding, self.dilation, self.groups)
302
303
RuntimeError: CuDNN error: CUDNN_STATUS_BAD_PARAM
In [5]: torch.backends.cudnn.enabled = False
In [6]: conv(tensor).shape
Out[6]: torch.Size([1, 1, 1, 1]) |
|
@ssnl col2vol and vol2col don't have shape checks at all currently, but I can make the change to im2col and col2im. |
|
@pytorchbot test this again |
|
@resistor pytorchbot retest this please |
|
@pytorchbot retest this please |
2 similar comments
|
@pytorchbot retest this please |
|
@pytorchbot retest this please |
|
Awesome. Could you add a test in |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ssnl has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@pytorchbot retest this please |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@ssnl has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Are making the same changes for THCUNN as well? The same bevahior happen in cuda tensors |
|
Should be simple enough to work around. |
|
@ezyang Those are existing errors. |
|
@fmassa I would prefer to address those in a separate change, as I am not currently setup to test CUDA. |
|
@resistor sounds good to me, but I think it is also very important to have consistent behavior between CPU and CUDA. |
3156543 to
c54f112
Compare
…utions involving striding and dilation.
|
@fmassa CUDA changes incorporated. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@resistor has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
…utions involving striding and dilation. Summary: Pull Request resolved: pytorch/pytorch#9640 Differential Revision: D8948081 Pulled By: resistor fbshipit-source-id: 06f2e3ad1bdb448be6f36577cb9bd27c884df595
…utions involving striding and dilation. Summary: Pull Request resolved: pytorch#9640 Differential Revision: D8948081 Pulled By: resistor fbshipit-source-id: 06f2e3ad1bdb448be6f36577cb9bd27c884df595
…utions involving striding and dilation. Summary: Pull Request resolved: pytorch#9640 Differential Revision: D8948081 Pulled By: resistor fbshipit-source-id: 06f2e3ad1bdb448be6f36577cb9bd27c884df595
Summary: Fixes #21935 by using the integer floor division that was introduced for convolution shapes in #9640. Without this fix, the pooling operators can produce a 1-element output in cases they shouldn't. Disclaimer: I couldn't properly test it locally (it's not picking up the modified version for some reason). I'm marking this WIP until I checked what the CI tools say... Pull Request resolved: #22304 Differential Revision: D16181955 Pulled By: ezyang fbshipit-source-id: a2405372753572548b40616d1206848b527c8121
Summary: Fixes pytorch/pytorch#21935 by using the integer floor division that was introduced for convolution shapes in pytorch/pytorch#9640. Without this fix, the pooling operators can produce a 1-element output in cases they shouldn't. Disclaimer: I couldn't properly test it locally (it's not picking up the modified version for some reason). I'm marking this WIP until I checked what the CI tools say... Pull Request resolved: pytorch/pytorch#22304 Differential Revision: D16181955 Pulled By: ezyang fbshipit-source-id: a2405372753572548b40616d1206848b527c8121
#9592