Fix inconsistent torch.nn.MaxPool1d output on cpu and gpu (#99843)
Fixes #99412 , correctly raising an error when an output of invalid size is calculated.
Would be happy to iterate on this if there are any issues.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/99843
Approved by: https://github.com/mikaylagawarecki