From: Edward Yang Date: Fri, 22 Mar 2019 14:46:50 +0000 (-0700) Subject: Add test for #17271 (torch.exp incorrect for 2**31 size tensor) (#18292) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~685 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e3da16a99eb4b475a90fe424eaf9156c3f7370f4;p=platform%2Fupstream%2Fpytorch.git Add test for #17271 (torch.exp incorrect for 2**31 size tensor) (#18292) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/18292 ghimport-source-id: a3e96584db0eef7b6202a1211808f9f6e59dd529 Stack from [ghstack](https://github.com/ezyang/ghstack): * **#18292 Add test for #17271 (torch.exp incorrect for 2**31 size tensor)** * #18291 Correctly call superclass setUp in TestCase subclasses. Signed-off-by: Edward Z. Yang Differential Revision: D14567642 fbshipit-source-id: c60ee7597a86f5d2c5c0b72cb106f17815950427 --- diff --git a/test/test_torch.py b/test/test_torch.py index 20563a6..5cc1ee8 100644 --- a/test/test_torch.py +++ b/test/test_torch.py @@ -766,6 +766,15 @@ class _TestTorchMixin(object): return inf self._test_math(torch.exp, exp) + @slowTest + def test_exp_slow(self): + # Test for https://github.com/pytorch/pytorch/issues/17271 + # This is pretty slow on my Macbook but it only takes a few + # seconds on a beefy Xeon server + a = torch.exp(torch.ones(2 ** 31, dtype=torch.float32)) + b = torch.exp(torch.ones(1, dtype=torch.float32)) + self.assertEqual(a, b.expand(2 ** 31)) + def test_expm1(self): def expm1(x): try: