pytorch/torch/csrc/lazy
Samuel Park df9a4824e6 Bugfix for doing negative padding (#161639)
Fixes #161014

This bug fix introduces a fix that is consistent with the exception handling. Outlined in issue #161014, there is an edge case where the negative padding does not make the tensor size negative but still triggers the exception that the size is negative. The fix is simply adding `new_dim >=0` to include the zero dim and letting the operator return an empty tensor.

In the PR I have added the edge case where the test will now check the negative padding where the dimension gets reduced to zero.  But the sample is only for the `constant` type of padding. I would like some feedback if it is necessary to put the same sample on the `reduce` type as well.

This is my first PR to contribute to PyTorch and any help/feedback will be welcome! Thank you!

@malfet @manuelcandales @janeyx99 @ezyang

Pull Request resolved: https://github.com/pytorch/pytorch/pull/161639
Approved by: https://github.com/manuelcandales
2025-09-19 20:57:05 +00:00
..
backend
core Bugfix for doing negative padding (#161639) 2025-09-19 20:57:05 +00:00
generated
python [BE] remove torch deploy - conditionals (#158288) 2025-07-29 17:40:49 +00:00
ts_backend Replace some calls to new with make_{unique,shared} (#160581) 2025-08-28 00:30:45 +00:00
test_mnist.py
tutorial.md [BE][7/16] fix typos in torch/ (torch/csrc/) (#156317) 2025-06-23 02:57:41 +00:00