From ef1f97f5badf67cdfad3b529fad9067a621942ae Mon Sep 17 00:00:00 2001 From: Johannes M Dieterich Date: Thu, 13 Sep 2018 14:44:40 -0500 Subject: [PATCH 1/5] Enable a few more tests, now that we have CPU LAPACK --- test/test_distributions.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/test_distributions.py b/test/test_distributions.py index 7ae77dead800e7..1ef0ef78873b95 100644 --- a/test/test_distributions.py +++ b/test/test_distributions.py @@ -713,7 +713,6 @@ def _check_enumerate_support(self, dist, examples): actual = dist(param).enumerate_support() self.assertEqual(actual, expected) - @skipIfRocm def test_sample_detached(self): for Dist, params in EXAMPLES: for i, param in enumerate(params): @@ -726,7 +725,6 @@ def test_sample_detached(self): msg='{} example {}/{}, .sample() is not detached'.format( Dist.__name__, i + 1, len(params))) - @skipIfRocm def test_rsample_requires_grad(self): for Dist, params in EXAMPLES: for i, param in enumerate(params): @@ -740,7 +738,6 @@ def test_rsample_requires_grad(self): msg='{} example {}/{}, .rsample() does not require grad'.format( Dist.__name__, i + 1, len(params))) - @skipIfRocm def test_enumerate_support_type(self): for Dist, params in EXAMPLES: for i, param in enumerate(params): @@ -752,7 +749,6 @@ def test_enumerate_support_type(self): except NotImplementedError: pass - @skipIfRocm def test_lazy_property_grad(self): x = torch.randn(1, requires_grad=True) @@ -1640,7 +1636,6 @@ def test_lowrank_multivariate_normal_properties(self): self.assertEqual(m1.precision_matrix, m2.precision_matrix) self.assertEqual(m1.entropy(), m2.entropy()) - @skipIfRocm def test_lowrank_multivariate_normal_moments(self): set_rng_seed(0) # see Note [Randomized statistical tests] mean = torch.randn(5) @@ -3277,7 +3272,6 @@ def test_kl_edgecases(self): self.assertEqual(kl_divergence(Bernoulli(1), Bernoulli(1)), 0) self.assertEqual(kl_divergence(Categorical(torch.tensor([0., 1.])), Categorical(torch.tensor([0., 1.]))), 0) - @skipIfRocm def test_kl_shape(self): for Dist, params in EXAMPLES: for i, param in enumerate(params): @@ -3293,7 +3287,6 @@ def test_kl_shape(self): 'Actual {}'.format(kl.shape), ])) - @skipIfRocm def test_entropy_monte_carlo(self): set_rng_seed(0) # see Note [Randomized statistical tests] for Dist, params in EXAMPLES: From 422387cfec324ae358fcde1d8ca92cc26269877a Mon Sep 17 00:00:00 2001 From: Johannes M Dieterich Date: Thu, 13 Sep 2018 17:42:15 -0500 Subject: [PATCH 2/5] Enable even more. --- test/test_distributions.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/test_distributions.py b/test/test_distributions.py index 1ef0ef78873b95..ae0852d37dfbcd 100644 --- a/test/test_distributions.py +++ b/test/test_distributions.py @@ -1648,7 +1648,6 @@ def test_lowrank_multivariate_normal_moments(self): empirical_var = samples.var(0) self.assertEqual(d.variance, empirical_var, prec=0.02) - @skipIfRocm def test_multivariate_normal_shape(self): mean = torch.randn(5, 3, requires_grad=True) mean_no_batch = torch.randn(3, requires_grad=True) @@ -1756,7 +1755,6 @@ def test_multivariate_normal_sample(self): 'MultivariateNormal(loc={}, scale_tril={})'.format(mean, scale_tril), multivariate=True) - @skipIfRocm def test_multivariate_normal_properties(self): loc = torch.randn(5) scale_tril = transform_to(constraints.lower_cholesky)(torch.randn(5, 5)) @@ -3144,7 +3142,6 @@ def test_kl_monte_carlo(self): # Multivariate normal has a separate Monte Carlo based test due to the requirement of random generation of # positive (semi) definite matrices. n is set to 5, but can be increased during testing. - @skipIfRocm def test_kl_multivariate_normal(self): set_rng_seed(0) # see Note [Randomized statistical tests] n = 5 # Number of tests for multivariate_normal @@ -3170,7 +3167,6 @@ def test_kl_multivariate_normal(self): 'Actual (analytic): {}'.format(actual), ])) - @skipIfRocm def test_kl_multivariate_normal_batched(self): b = 7 # Number of batches loc = [torch.randn(b, 3) for _ in range(0, 2)] @@ -3182,7 +3178,6 @@ def test_kl_multivariate_normal_batched(self): MultivariateNormal(loc[1], scale_tril=scale_tril[1])) self.assertEqual(expected_kl, actual_kl) - @skipIfRocm def test_kl_multivariate_normal_batched_broadcasted(self): b = 7 # Number of batches loc = [torch.randn(b, 3) for _ in range(0, 2)] @@ -3195,7 +3190,6 @@ def test_kl_multivariate_normal_batched_broadcasted(self): MultivariateNormal(loc[1], scale_tril=scale_tril[1])) self.assertEqual(expected_kl, actual_kl) - @skipIfRocm def test_kl_lowrank_multivariate_normal(self): set_rng_seed(0) # see Note [Randomized statistical tests] n = 5 # Number of tests for lowrank_multivariate_normal @@ -3236,7 +3230,6 @@ def test_kl_lowrank_multivariate_normal(self): 'Actual (analytic): {}'.format(actual_full_lowrank), ])) - @skipIfRocm def test_kl_lowrank_multivariate_normal_batched(self): b = 7 # Number of batches loc = [torch.randn(b, 3) for _ in range(0, 2)] @@ -4028,7 +4021,6 @@ def setUp(self): super(TestCase, self).setUp() Distribution.set_default_validate_args(True) - @skipIfRocm def test_valid(self): for Dist, params in EXAMPLES: for i, param in enumerate(params): From ba2b73d0cf2a76958906a8289f19d3de78e66119 Mon Sep 17 00:00:00 2001 From: Johannes M Dieterich Date: Fri, 14 Sep 2018 10:37:40 -0500 Subject: [PATCH 3/5] Enable everything - let's see the fallout. --- test/test_distributions.py | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/test/test_distributions.py b/test/test_distributions.py index ae0852d37dfbcd..469c4fc77f2144 100644 --- a/test/test_distributions.py +++ b/test/test_distributions.py @@ -1117,7 +1117,6 @@ def test_poisson_sample(self): @unittest.skipIf(not TEST_CUDA, "CUDA not found") @unittest.skipIf(not TEST_NUMPY, "Numpy not found") - @skipIfRocm def test_poisson_gpu_sample(self): set_rng_seed(1) for rate in [0.12, 0.9, 4.0]: @@ -1525,7 +1524,6 @@ def test_normal_sample(self): scipy.stats.norm(loc=loc, scale=scale), 'Normal(mean={}, std={})'.format(loc, scale)) - @skipIfRocm def test_lowrank_multivariate_normal_shape(self): mean = torch.randn(5, 3, requires_grad=True) mean_no_batch = torch.randn(3, requires_grad=True) @@ -1574,7 +1572,6 @@ def test_lowrank_multivariate_normal_shape(self): (mean_multi_batch, cov_factor_batched, cov_diag_batched)) @unittest.skipIf(not TEST_NUMPY, "Numpy not found") - @skipIfRocm def test_lowrank_multivariate_normal_log_prob(self): mean = torch.randn(3, requires_grad=True) cov_factor = torch.randn(3, 1, requires_grad=True) @@ -1608,7 +1605,6 @@ def test_lowrank_multivariate_normal_log_prob(self): self.assertAlmostEqual(0.0, (batched_prob - unbatched_prob).abs().max(), places=3) @unittest.skipIf(not TEST_NUMPY, "NumPy not found") - @skipIfRocm def test_lowrank_multivariate_normal_sample(self): set_rng_seed(0) # see Note [Randomized statistical tests] mean = torch.randn(5, requires_grad=True) @@ -1621,7 +1617,6 @@ def test_lowrank_multivariate_normal_sample(self): 'LowRankMultivariateNormal(loc={}, cov_factor={}, cov_diag={})' .format(mean, cov_factor, cov_diag), multivariate=True) - @skipIfRocm def test_lowrank_multivariate_normal_properties(self): loc = torch.randn(5) cov_factor = torch.randn(5, 2) @@ -1695,7 +1690,6 @@ def test_multivariate_normal_shape(self): self._gradcheck_log_prob(MultivariateNormal, (mean_no_batch, None, None, scale_tril_batched)) @unittest.skipIf(not TEST_NUMPY, "Numpy not found") - @skipIfRocm def test_multivariate_normal_log_prob(self): mean = torch.randn(3, requires_grad=True) tmp = torch.randn(3, 10) @@ -1733,7 +1727,6 @@ def test_multivariate_normal_log_prob(self): self.assertAlmostEqual(0.0, (batched_prob - unbatched_prob).abs().max(), places=3) @unittest.skipIf(not TEST_NUMPY, "NumPy not found") - @skipIfRocm def test_multivariate_normal_sample(self): set_rng_seed(0) # see Note [Randomized statistical tests] mean = torch.randn(3, requires_grad=True) @@ -1883,7 +1876,6 @@ def ref_log_prob(idx, x, log_prob): @unittest.skipIf(not TEST_CUDA, "CUDA not found") @unittest.skipIf(not TEST_NUMPY, "NumPy not found") - @skipIfRocm def test_gamma_gpu_shape(self): alpha = torch.tensor(torch.exp(torch.randn(2, 3).cuda()), requires_grad=True) beta = torch.tensor(torch.exp(torch.randn(2, 3).cuda()), requires_grad=True) @@ -1914,7 +1906,6 @@ def test_gamma_sample(self): @unittest.skipIf(not TEST_CUDA, "CUDA not found") @unittest.skipIf(not TEST_NUMPY, "Numpy not found") - @skipIfRocm def test_gamma_gpu_sample(self): set_rng_seed(0) for alpha, beta in product([0.1, 1.0, 5.0], [0.1, 1.0, 10.0]): @@ -2147,7 +2138,6 @@ def test_beta_sample(self): x = Beta(Tensor([1e-6]), Tensor([1e-6])).sample()[0] self.assertTrue(np.isfinite(x) and x > 0, 'Invalid Beta.sample(): {}'.format(x)) - @skipIfRocm def test_independent_shape(self): for Dist, params in EXAMPLES: for i, param in enumerate(params): @@ -2176,7 +2166,6 @@ def test_independent_shape(self): except NotImplementedError: pass - @skipIfRocm def test_cdf_icdf_inverse(self): # Tests the invertibility property on the distributions for Dist, params in EXAMPLES: @@ -2196,7 +2185,6 @@ def test_cdf_icdf_inverse(self): 'icdf(cdf(x)) = {}'.format(actual), ])) - @skipIfRocm def test_cdf_log_prob(self): # Tests if the differentiation of the CDF gives the PDF at a given value for Dist, params in EXAMPLES: @@ -2588,7 +2576,6 @@ def tearDown(self): super(TestCase, self).tearDown() Distribution.set_default_validate_args(False) - @skipIfRocm def test_entropy_shape(self): for Dist, params in EXAMPLES: for i, param in enumerate(params): @@ -3323,7 +3310,6 @@ def test_entropy_exponential_family(self): class TestConstraints(TestCase): - @skipIfRocm def test_params_contains(self): for Dist, params in EXAMPLES: for i, param in enumerate(params): @@ -3347,7 +3333,6 @@ def test_params_contains(self): Dist.__name__, i + 1, len(params), name, value) self.assertTrue(constraint.check(value).all(), msg=message) - @skipIfRocm def test_support_contains(self): for Dist, params in EXAMPLES: self.assertIsInstance(Dist.support, Constraint) @@ -3627,7 +3612,6 @@ def setUp(self): ) ] - @skipIfRocm def test_mean(self): for pytorch_dist, scipy_dist in self.distribution_pairs: if isinstance(pytorch_dist, (Cauchy, HalfCauchy)): @@ -3638,7 +3622,6 @@ def test_mean(self): else: self.assertEqual(pytorch_dist.mean, scipy_dist.mean(), allow_inf=True, message=pytorch_dist) - @skipIfRocm def test_variance_stddev(self): for pytorch_dist, scipy_dist in self.distribution_pairs: if isinstance(pytorch_dist, (Cauchy, HalfCauchy)): @@ -3654,7 +3637,6 @@ def test_variance_stddev(self): self.assertEqual(pytorch_dist.variance, scipy_dist.var(), allow_inf=True, message=pytorch_dist) self.assertEqual(pytorch_dist.stddev, scipy_dist.var() ** 0.5, message=pytorch_dist) - @skipIfRocm def test_cdf(self): for pytorch_dist, scipy_dist in self.distribution_pairs: samples = pytorch_dist.sample((5,)) @@ -3664,7 +3646,6 @@ def test_cdf(self): continue self.assertEqual(cdf, scipy_dist.cdf(samples), message=pytorch_dist) - @skipIfRocm def test_icdf(self): for pytorch_dist, scipy_dist in self.distribution_pairs: samples = torch.rand((5,) + pytorch_dist.batch_shape) @@ -3970,7 +3951,6 @@ def test_biject_to(self): self.assertEqual(j.shape, x.shape[:x.dim() - t.event_dim]) @unittest.skipIf(not TEST_CUDA, "CUDA not found") - @skipIfRocm def test_biject_to_cuda(self): for constraint in self.get_constraints(is_cuda=True): try: @@ -4003,7 +3983,6 @@ def test_transform_to(self): self.assertEqual(y, y2, message="Error in transform_to({}) pseudoinverse".format(constraint)) @unittest.skipIf(not TEST_CUDA, "CUDA not found") - @skipIfRocm def test_transform_to_cuda(self): for constraint in self.get_constraints(is_cuda=True): t = transform_to(constraint) From 98c5cd8426a5f9fc9299999ae70abac482a06948 Mon Sep 17 00:00:00 2001 From: Johannes M Dieterich Date: Fri, 14 Sep 2018 11:39:06 -0500 Subject: [PATCH 4/5] Unrecognized tensor type ID. --- test/test_distributions.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_distributions.py b/test/test_distributions.py index 469c4fc77f2144..d41b5bf705932f 100644 --- a/test/test_distributions.py +++ b/test/test_distributions.py @@ -1117,6 +1117,7 @@ def test_poisson_sample(self): @unittest.skipIf(not TEST_CUDA, "CUDA not found") @unittest.skipIf(not TEST_NUMPY, "Numpy not found") + @skipIfRocm def test_poisson_gpu_sample(self): set_rng_seed(1) for rate in [0.12, 0.9, 4.0]: From 34b08645a2ac87cd84b1f5af4612b66d5567bb42 Mon Sep 17 00:00:00 2001 From: Johannes M Dieterich Date: Fri, 14 Sep 2018 13:03:08 -0500 Subject: [PATCH 5/5] Skip two tests that cause a runtime error (wrong type, test_transform_to_cuda) and a assertion error (wrong result, test_gamma_gpu_sample) --- test/test_distributions.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_distributions.py b/test/test_distributions.py index d41b5bf705932f..8a4048dad9be20 100644 --- a/test/test_distributions.py +++ b/test/test_distributions.py @@ -1907,6 +1907,7 @@ def test_gamma_sample(self): @unittest.skipIf(not TEST_CUDA, "CUDA not found") @unittest.skipIf(not TEST_NUMPY, "Numpy not found") + @skipIfRocm def test_gamma_gpu_sample(self): set_rng_seed(0) for alpha, beta in product([0.1, 1.0, 5.0], [0.1, 1.0, 10.0]): @@ -3984,6 +3985,7 @@ def test_transform_to(self): self.assertEqual(y, y2, message="Error in transform_to({}) pseudoinverse".format(constraint)) @unittest.skipIf(not TEST_CUDA, "CUDA not found") + @skipIfRocm def test_transform_to_cuda(self): for constraint in self.get_constraints(is_cuda=True): t = transform_to(constraint)