-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Closed
Labels
module: edge casesAdversarial inputs unlikely to occur in practiceAdversarial inputs unlikely to occur in practicemodule: error checkingBugs related to incorrect/lacking error checkingBugs related to incorrect/lacking error checkingtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
π΅οΈββοΈ Detected with FACTO
π Describe the bug
The aten op constant_pad_nd allows for negative padding, as long as the absolute value of the padding is smaller than the size, and as long as the resulting output doesn't have negative size
For example:
>>> torch.ops.aten.constant_pad_nd.default(torch.ones([5, 3]), [-1, -2]).shape
torch.Size([5, 0])Notice that the -1, -2 padding applies to the last dimension
We can also pad the first dimension, by adding two more pads:
>>> torch.ops.aten.constant_pad_nd.default(torch.ones([5, 3]), [-1, -2, 0, 0]).shape
torch.Size([5, 0])
>>> torch.ops.aten.constant_pad_nd.default(torch.ones([5, 3]), [-1, -2, -1, -1]).shape
torch.Size([3, 0])However, in the following case, it throws an error:
>>> torch.ops.aten.constant_pad_nd.default(torch.ones([5, 3]), [-1, -2, 1, 1]).shape
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/mcandales/miniconda3/envs/facto/lib/python3.11/site-packages/torch/_ops.py", line 840, in __call__
return self._op(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: The input size 3, plus negative padding -1 and -2 resulted in a negative output size, which is invalid. Check dimension 1 of your input.Notice that, if we make sure the output won't have size 0, we always avoid the bug:
>>> torch.ops.aten.constant_pad_nd.default(torch.ones([5, 3]), [-1, -1, 1, 1]).shape
torch.Size([7, 1])Versions
nightly
cc @malfet
Metadata
Metadata
Assignees
Labels
module: edge casesAdversarial inputs unlikely to occur in practiceAdversarial inputs unlikely to occur in practicemodule: error checkingBugs related to incorrect/lacking error checkingBugs related to incorrect/lacking error checkingtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module