Skip to content

cherrypick fixes to unit tests #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions aten/src/ATen/cuda/CUDAContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ Allocator* getCUDADeviceAllocator() {
}

/* Handles */
#ifndef __HIP_PLATFORM_HCC__
cusparseHandle_t getCurrentCUDASparseHandle() {
return THCState_getCurrentSparseHandle(at::globalContext().getTHCState());
}
cusparseHandle_t getCurrentCUDASparseHandle() {
return THCState_getCurrentSparseHandle(at::globalContext().getTHCState());
}

cublasHandle_t getCurrentCUDABlasHandle() {
return THCState_getCurrentBlasHandle(at::globalContext().getTHCState());
}
#endif
cublasHandle_t getCurrentCUDABlasHandle() {
return THCState_getCurrentBlasHandle(at::globalContext().getTHCState());
}

} // namespace cuda

Expand Down
2 changes: 0 additions & 2 deletions aten/src/ATen/cuda/CUDAContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@ CAFFE2_API void uncheckedSetCurrentCUDAStream(CUDAStream stream);
CAFFE2_API Allocator* getCUDADeviceAllocator();

/* Handles */
#ifndef __HIP_PLATFORM_HCC__
CAFFE2_API cusparseHandle_t getCurrentCUDASparseHandle();
CAFFE2_API cublasHandle_t getCurrentCUDABlasHandle();
#endif


} // namespace cuda
Expand Down
1 change: 1 addition & 0 deletions test/test_autograd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,6 +1406,7 @@ def test_unused_output(self):
expected_grad[:2] = grad_output
self.assertEqual(x.grad.data, expected_grad)

@skipIfRocm
def test_ctc_loss(self):
batch_size = 64
num_labels = 101
Expand Down
10 changes: 5 additions & 5 deletions test/test_cuda.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ def tmp(t):
('div', small_3d, lambda t: [number(3.14, 3, t)], '', types, False,
"skipIfRocm:ByteTensor,CharTensor,FloatTensor,HalfTensor,ShortTensor"),
('div', small_3d, lambda t: [small_3d_positive(t)], 'tensor'),
('pow', small_3d, lambda t: [number(3.14, 3, t)], None, float_types, False, "skipIfRocm:HalfTensor"),
('pow', small_3d, lambda t: [number(1., 1, t)], 'pow1', types, False, "skipIfRocm:HalfTensor"),
('pow', small_3d, lambda t: [number(2., 2, t)], 'pow2', types, False, "skipIfRocm:HalfTensor"),
('pow', small_3d, lambda t: [number(3., 3, t)], 'pow3', types, False, "skipIfRocm:HalfTensor"),
('pow', small_3d, lambda t: [number(-1., -1, t)], 'pow-1', float_types, False, "skipIfRocm:HalfTensor"),
('pow', small_3d, lambda t: [number(3.14, 3, t)], None, float_types),
('pow', small_3d, lambda t: [number(1., 1, t)], 'pow1'),
('pow', small_3d, lambda t: [number(2., 2, t)], 'pow2'),
('pow', small_3d, lambda t: [number(3., 3, t)], 'pow3'),
('pow', small_3d, lambda t: [number(-1., -1, t)], 'pow-1', float_types),
# HalfTensor gives bad result at pow-2 with data sampled from torch.randn
('pow', small_3d, lambda t: [number(-2., -2, t)], 'pow-2', float_types_no_half,
False, "skipIfRocm:HalfTensor,FloatTensor"),
Expand Down
1 change: 1 addition & 0 deletions test/test_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ def test_segfault(self):
finally:
p.terminate()

@skipIfRocm
def test_timeout(self):
p = ErrorTrackingProcess(target=_test_timeout)
p.start()
Expand Down
3 changes: 3 additions & 0 deletions test/test_jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -7243,6 +7243,7 @@ def test_dcgan_models(self):
self._test_dcgan_models(self, device='cpu')

@unittest.skipIf(not RUN_CUDA, "no CUDA")
@skipIfRocm
def test_dcgan_models_cuda(self):
# XXX: export_import on CUDA modules doesn't work (#11480)
self._test_dcgan_models(self, device='cuda', check_export_import=False)
Expand Down Expand Up @@ -7365,11 +7366,13 @@ def test_mnist(self):
self._test_mnist(self, device='cpu')

@unittest.skipIf(not RUN_CUDA, "no CUDA")
@skipIfRocm
def test_mnist_cuda(self):
# XXX: export_import on CUDA modules doesn't work (#11480)
self._test_mnist(self, device='cuda', check_export_import=False)

@unittest.skipIf(not RUN_CUDA, "no CUDA")
@skipIfRocm
def test_mnist_training_leaks_no_memory_cuda(self):
net = MnistNet().cuda()
# MnistNet uses dropout, don't check its trace
Expand Down
1 change: 1 addition & 0 deletions test/test_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4202,6 +4202,7 @@ def get_inputs(input_shape, hidden_shape, mode):
test(input_shape, hidden_shape, mode)

@unittest.skipIf(not TEST_MULTIGPU, "multi-GPU not supported")
@skipIfRocm
def test_rnn_check_device(self):
input_size = 3
hidden_size = 5
Expand Down
3 changes: 3 additions & 0 deletions test/test_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,7 @@ def _all_narrow_combs(self, shape):
for length in range(dim_sz - start):
yield [dim, start, length]

@skipIfRocm
def test_narrow(self):
shape = [3, 3, 4, 2]
input, _, _ = self._gen_sparse(4, 19, shape)
Expand Down Expand Up @@ -1437,6 +1438,7 @@ def test_tensor(indices, values, indices_equal, values_equal):
test_tensor(indices, values, False, True) # An empty tensor's data_ptr is always equal to 0

@cpu_only # just run once, we test both cpu and cuda
@skipIfRocm
def test_constructor_device_legacy(self):
i = torch.tensor([[0, 1, 1], [2, 0, 2]])
v = torch.tensor([3., 4., 5.])
Expand Down Expand Up @@ -1583,6 +1585,7 @@ def test_resize(self):
self._test_resize_shape([1, 1], [1, 2, 3], [2, 2, 3],
[1, 1], [1, 2, 0], [2, 2, 0])

@skipIfRocm
def test_is_nonzero(self):
self.assertTrue(torch.sparse_coo_tensor(([0],), 1., (1,)).is_nonzero())
self.assertFalse(torch.sparse_coo_tensor(([0],), 0., (1,)).is_nonzero())
Expand Down
5 changes: 5 additions & 0 deletions test/test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3999,6 +3999,7 @@ def test_is_signed_cuda(self):
self.assertEqual(torch.cuda.HalfTensor(10).is_signed(), True)

@skipIfNoLapack
@skipIfRocm
def test_gesv(self):
a = torch.Tensor(((6.80, -2.11, 5.66, 5.97, 8.23),
(-6.05, -3.30, 5.36, -4.44, 1.08),
Expand Down Expand Up @@ -4130,6 +4131,7 @@ def test_gesv_batched_dims(self):
self._test_gesv_batched_dims(self, lambda t: t)

@skipIfNoLapack
@skipIfRocm
def test_qr(self):

# Since the QR decomposition is unique only up to the signs of the rows of
Expand Down Expand Up @@ -4312,10 +4314,12 @@ def _test_trtrs(self, cast):
self.assertEqual(res1, tb, 0)

@skipIfNoLapack
@skipIfRocm
def test_trtrs(self):
self._test_trtrs(self, lambda t: t)

@skipIfNoLapack
@skipIfRocm
def test_gels(self):
def _test_underdetermined(a, b, expectedNorm):
m = a.size()[0]
Expand Down Expand Up @@ -4431,6 +4435,7 @@ def check_norm(a, b, expected_norm, gels_result):
self.assertEqual((torch.mm(a, tb) - b).norm(), expectedNorm, 1e-8)

@skipIfNoLapack
@skipIfRocm
def test_eig(self):
a = torch.Tensor(((1.96, 0.00, 0.00, 0.00, 0.00),
(-6.49, 3.80, 0.00, 0.00, 0.00),
Expand Down