Throw invalid_argument instead of RuntimeError when parameters exceed… (#158267)

Throw invalid_argument instead of RuntimeError when parameters exceed limits (for torch.int32 dtype)

Fixes #157707

Pull Request resolved: https://github.com/pytorch/pytorch/pull/158267
Approved by: https://github.com/albanD
This commit is contained in:
gaoyufeng
2025-07-25 23:49:42 +00:00
committed by PyTorch MergeBot
parent 21a95bdf7c
commit f5cf05c983
4 changed files with 14 additions and 18 deletions

View File

@ -488,7 +488,7 @@ class TestNumPyInterop(TestCase):
) # type: ignore[call-overload]
else:
self.assertRaisesRegex(
RuntimeError,
ValueError,
"(Overflow|an integer is required)",
lambda: torch.mean(torch.randn(1, 1), np.uint64(-1)),
) # type: ignore[call-overload]