use UBSAN on some tests (#103655)

Fixes #ISSUE_NUMBER

Pull Request resolved: https://github.com/pytorch/pytorch/pull/103655
Approved by: https://github.com/kshitij12345, https://github.com/zou3519
This commit is contained in:
cyy
2023-07-24 14:24:49 +00:00
committed by PyTorch MergeBot
parent 68dce23722
commit b8eb827d93
3 changed files with 2 additions and 14 deletions

View File

@ -44,7 +44,7 @@ torch.set_default_dtype(torch.double)
from torch import inf, nan
from torch.testing._internal.common_utils import \
(TestCase, run_tests, set_rng_seed, TEST_WITH_UBSAN, load_tests,
(TestCase, run_tests, set_rng_seed, load_tests,
gradcheck, skipIfTorchDynamo)
from torch.testing._internal.common_cuda import TEST_CUDA
from torch.autograd import grad
@ -5003,7 +5003,6 @@ class TestValidation(DistributionsTestCase):
fail_string.format(Dist.__name__, i + 1, len(params))
) from e
@unittest.skipIf(TEST_WITH_UBSAN, "division-by-zero error with UBSAN")
def test_invalid(self):
for Dist, params in BAD_EXAMPLES:
for i, param in enumerate(params):

View File

@ -26,7 +26,6 @@ from torch.testing._internal.common_utils import (
parametrize,
instantiate_parametrized_tests,
subtest,
TEST_WITH_UBSAN,
skipIfRocm,
)
from torch.testing._internal.common_device_type import \
@ -3596,12 +3595,6 @@ class TestVmapOperatorsOpInfo(TestCase):
# TypeError: expected Tensor as element 0 in argument 0, but got float
xfail('item'),
# UBSAN: runtime error: shift exponent -1 is negative
decorate('bitwise_left_shift', decorator=unittest.skipIf(TEST_WITH_UBSAN, "Fails with above error")),
decorate('bitwise_right_shift', decorator=unittest.skipIf(TEST_WITH_UBSAN, "Fails with above error")),
# UBSAN: runtime error: -1e+20 is outside the range of representable values of type 'long'
decorate('special.hermite_polynomial_h', decorator=unittest.skipIf(TEST_WITH_UBSAN, "Fails with above error")),
}))
def test_vmap_exhaustive(self, device, dtype, op):
# needs to be fixed
@ -3735,9 +3728,6 @@ class TestVmapOperatorsOpInfo(TestCase):
xfail('linalg.lu', ''),
skip('linalg.ldl_solve', ''),
skip('_softmax_backward_data'),
# UBSAN: runtime error: shift exponent -1 is negative
decorate('bitwise_left_shift', decorator=unittest.skipIf(TEST_WITH_UBSAN, "Fails with above error")),
decorate('bitwise_right_shift', decorator=unittest.skipIf(TEST_WITH_UBSAN, "Fails with above error")),
# https://github.com/pytorch/pytorch/issues/96560
decorate('nn.functional.batch_norm', decorator=skipIfRocm),
decorate('nn.functional.instance_norm', decorator=skipIfRocm),

View File

@ -22,7 +22,7 @@ from torch.nn import Parameter
from torch.testing._internal import opinfo
from torch.testing._internal.common_utils import \
(gradcheck, gradgradcheck, run_tests, TestCase, download_file, IS_CI, NoTest,
TEST_WITH_UBSAN, skipIfSlowGradcheckEnv, suppress_warnings)
skipIfSlowGradcheckEnv, suppress_warnings)
from torch.testing import make_tensor
from torch.testing._internal.common_dtype import get_all_dtypes, integral_types
import torch.backends.mps
@ -4159,7 +4159,6 @@ class TestNLLLoss(TestCaseMPS):
self._nll_loss_helper([2, 3, 5, 1], "none", torch.empty([2, 5, 1], device=device))
self._nll_loss_helper([2, 3, 5, 7, 1], "none", torch.empty([2, 5, 7, 1], device=device))
@unittest.skipIf(TEST_WITH_UBSAN, "division-by-zero error with UBSAN")
def test_nll_loss_empty_tensor_reduction_mean(self, device='cpu'):
nan = torch.tensor(float('nan'), device=device)
self._nll_loss_helper([1, 3], "mean", nan)