Created
July 26, 2019 05:34
-
-
Save syed-ahmed/dad73d10ee5fdcda675102bcb02e66fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/test/common_quantization.py b/test/common_quantization.py | |
index 188fbf200..13dbc6358 100644 | |
--- a/test/common_quantization.py | |
+++ b/test/common_quantization.py | |
@@ -55,6 +55,10 @@ class QuantizationTestCase(TestCase): | |
self.train_data = [(torch.rand(20, 5, dtype=torch.float), torch.randint(0, 1, (20,), dtype=torch.long)) for _ in range(20)] | |
self.img_data = [(torch.rand(20, 3, 10, 10, dtype=torch.float), torch.randint(0, 1, (20,), dtype=torch.long)) | |
for _ in range(20)] | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def checkNoPrepModules(self, module): | |
r"""Checks the module does not contain child | |
diff --git a/test/common_utils.py b/test/common_utils.py | |
index 6384b8683..6606d9c60 100644 | |
--- a/test/common_utils.py | |
+++ b/test/common_utils.py | |
@@ -465,6 +465,10 @@ class TestCase(expecttest.TestCase): | |
raise unittest.SkipTest("test is fast; we disabled it with PYTORCH_TEST_SKIP_FAST") | |
set_rng_seed(SEED) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def assertTensorsSlowEqual(self, x, y, prec=None, message=''): | |
max_err = 0 | |
diff --git a/test/jit_utils.py b/test/jit_utils.py | |
index e98f64fcb..384fc9ed3 100644 | |
--- a/test/jit_utils.py | |
+++ b/test/jit_utils.py | |
@@ -72,6 +72,10 @@ class JitTestCase(TestCase): | |
torch.jit.TracerWarning.ignore_lib_warnings() | |
JitTestCase._restored_warnings = True | |
self.setHooks() | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def tearDown(self): | |
super(JitTestCase, self).tearDown() | |
diff --git a/test/test_c10d.py b/test/test_c10d.py | |
index 3196cd7bc..e3ec199c5 100644 | |
--- a/test/test_c10d.py | |
+++ b/test/test_c10d.py | |
@@ -241,6 +241,10 @@ class FileStoreTest(TestCase, StoreTestBase): | |
def setUp(self): | |
super(FileStoreTest, self).setUp() | |
self.file = tempfile.NamedTemporaryFile(delete=False) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def _create_store(self): | |
store = c10d.FileStore(self.file.name, 1) | |
@@ -255,6 +259,10 @@ class PrefixFileStoreTest(TestCase, StoreTestBase): | |
self.filestore = c10d.FileStore(self.file.name, 1) | |
self.prefix = "test_prefix" | |
self.filestore.set_timeout(timedelta(seconds=300)) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def _create_store(self): | |
return c10d.PrefixStore(self.prefix, self.filestore) | |
@@ -301,6 +309,10 @@ class PrefixTCPStoreTest(TestCase, StoreTestBase): | |
self.tcpstore = create_tcp_store('localhost') | |
self.prefix = "test_prefix" | |
self.tcpstore.set_timeout(timedelta(seconds=300)) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def _create_store(self): | |
return c10d.PrefixStore(self.prefix, self.tcpstore) | |
@@ -519,6 +531,10 @@ class MultiProcessTestCase(TestCase): | |
self.rank = self.MAIN_PROCESS_RANK | |
self.file = tempfile.NamedTemporaryFile(delete=False) | |
self.processes = [self._spawn_process(rank) for rank in range(int(self.world_size))] | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def tearDown(self): | |
super(MultiProcessTestCase, self).tearDown() | |
@@ -2781,6 +2797,10 @@ class ReducerTest(TestCase): | |
def setUp(self): | |
self.store = c10d.FileStore("/dev/null", 1) | |
self.process_group = c10d.ProcessGroupGloo(self.store, 0, 1) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def test_single_dtype_single_bucket(self): | |
model = ReducerModule() | |
diff --git a/test/test_cpp_extensions.py b/test/test_cpp_extensions.py | |
index 72fc899e4..a05d0a56a 100644 | |
--- a/test/test_cpp_extensions.py | |
+++ b/test/test_cpp_extensions.py | |
@@ -54,6 +54,10 @@ class TestCppExtension(common.TestCase): | |
default_build_root = torch.utils.cpp_extension.get_default_build_root() | |
if os.path.exists(default_build_root): | |
shutil.rmtree(default_build_root) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def test_extension_function(self): | |
x = torch.randn(4, 4) | |
diff --git a/test/test_dataloader.py b/test/test_dataloader.py | |
index 38e3d13d3..1db5c7948 100644 | |
--- a/test/test_dataloader.py | |
+++ b/test/test_dataloader.py | |
@@ -647,6 +647,10 @@ class TestDataLoader(TestCase): | |
self.data = torch.randn(100, 2, 3, 5) | |
self.labels = torch.randperm(50).repeat(2) | |
self.dataset = TensorDataset(self.data, self.labels) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def _test_sequential(self, loader): | |
batch_size = loader.batch_size | |
@@ -1458,6 +1462,10 @@ class TestStringDataLoader(TestCase): | |
def setUp(self): | |
super(TestStringDataLoader, self).setUp() | |
self.dataset = StringDataset() | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
@unittest.skipIf(not TEST_CUDA, "CUDA unavailable") | |
def test_shuffle_pin_memory(self): | |
@@ -1484,6 +1492,10 @@ class TestDictDataLoader(TestCase): | |
def setUp(self): | |
super(TestDictDataLoader, self).setUp() | |
self.dataset = DictDataset() | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def test_sequential_batch(self): | |
loader = DataLoader(self.dataset, batch_size=2, shuffle=False) | |
@@ -1528,6 +1540,10 @@ class TestNamedTupleDataLoader(TestCase): | |
def setUp(self): | |
super(TestNamedTupleDataLoader, self).setUp() | |
self.dataset = NamedTupleDataset() | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
@unittest.skipIf(not TEST_CUDA, "CUDA unavailable") | |
def test_collate_and_pin_memory_with_namedtuple(self): | |
@@ -1576,6 +1592,10 @@ class TestCustomPinFn(TestCase): | |
inps = torch.arange(10 * 5, dtype=torch.float32).view(10, 5) | |
tgts = torch.arange(10 * 5, dtype=torch.float32).view(10, 5) | |
self.dataset = TensorDataset(inps, tgts) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
@unittest.skipIf(not TEST_CUDA, "CUDA unavailable") | |
@skipIfRocm | |
@@ -1627,6 +1647,10 @@ class TestIndividualWorkerQueue(TestCase): | |
def setUp(self): | |
super(TestIndividualWorkerQueue, self).setUp() | |
self.dataset = TestWorkerQueueDataset([i for i in range(128)]) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def _run_ind_worker_queue_test(self, batch_size, num_workers): | |
loader = DataLoader( | |
diff --git a/test/test_distributed.py b/test/test_distributed.py | |
index 5c4fedad2..5a818734a 100644 | |
--- a/test/test_distributed.py | |
+++ b/test/test_distributed.py | |
@@ -1617,6 +1617,10 @@ if BACKEND == "gloo" or BACKEND == "nccl": | |
Barrier.init() | |
for rank in range(int(WORLD_SIZE)): | |
self.processes.append(self._spawn_process(rank)) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def tearDown(self): | |
super(TestDistBackend, self).tearDown() | |
diff --git a/test/test_distributions.py b/test/test_distributions.py | |
index 62a19cd1b..2ca1e1b62 100644 | |
--- a/test/test_distributions.py | |
+++ b/test/test_distributions.py | |
@@ -2727,6 +2727,10 @@ class TestDistributionShapes(TestCase): | |
self.tensor_sample_1 = torch.ones(3, 2) | |
self.tensor_sample_2 = torch.ones(3, 2, 3) | |
Distribution.set_default_validate_args(True) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def tearDown(self): | |
super(TestDistributionShapes, self).tearDown() | |
@@ -3111,6 +3115,10 @@ class TestKL(TestCase): | |
def setUp(self): | |
super(TestKL, self).setUp() | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
class Binomial30(Binomial): | |
def __init__(self, probs): | |
@@ -3628,6 +3636,10 @@ class TestLazyLogitsInitialization(TestCase): | |
super(TestLazyLogitsInitialization, self).setUp() | |
self.examples = [e for e in EXAMPLES if e.Dist in | |
(Categorical, OneHotCategorical, Bernoulli, Binomial, Multinomial)] | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def test_lazy_logits_initialization(self): | |
for Dist, params in self.examples: | |
@@ -3772,6 +3784,10 @@ class TestAgainstScipy(TestCase): | |
scipy.stats.weibull_min(c=positive_var2[0], scale=positive_var[0]) | |
) | |
] | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def test_mean(self): | |
for pytorch_dist, scipy_dist in self.distribution_pairs: | |
@@ -3870,6 +3886,10 @@ class TestTransforms(TestCase): | |
self.transforms += transforms | |
if cache_size == 0: | |
self.unique_transforms = transforms[:] | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def _generate_data(self, transform): | |
domain = transform.domain | |
@@ -4312,6 +4332,10 @@ class TestValidation(TestCase): | |
def setUp(self): | |
super(TestCase, self).setUp() | |
Distribution.set_default_validate_args(True) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def test_valid(self): | |
for Dist, params in EXAMPLES: | |
diff --git a/test/test_nn.py b/test/test_nn.py | |
index 0d663c1c4..b5155d819 100644 | |
--- a/test/test_nn.py | |
+++ b/test/test_nn.py | |
@@ -8905,6 +8905,10 @@ class TestNNInit(TestCase): | |
def setUp(self): | |
super(TestNNInit, self).setUp() | |
random.seed(123) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def _is_normal(self, tensor, mean, std): | |
samples = tensor.view(-1).tolist() | |
diff --git a/test/test_optim.py b/test/test_optim.py | |
index e334962c9..aa0b1c11e 100644 | |
--- a/test/test_optim.py | |
+++ b/test/test_optim.py | |
@@ -541,6 +541,10 @@ class TestLRScheduler(TestCase): | |
self.opt = SGD( | |
[{'params': self.net.conv1.parameters()}, {'params': self.net.conv2.parameters(), 'lr': 0.5}], | |
lr=0.05) | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def test_old_pattern_warning(self): | |
epochs = 35 | |
diff --git a/test/test_sparse.py b/test/test_sparse.py | |
index e105f9113..201f3d61a 100644 | |
--- a/test/test_sparse.py | |
+++ b/test/test_sparse.py | |
@@ -60,6 +60,10 @@ class TestSparse(TestCase): | |
self.sparse_tensor = sparse_tensor_factory | |
self.legacy_sparse_tensor = torch.sparse.DoubleTensor | |
super(TestSparse, self).setUp() | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def _gen_sparse(self, sparse_dim, nnz, with_size): | |
if isinstance(with_size, Number): | |
diff --git a/test/test_utils.py b/test/test_utils.py | |
index 0970f6656..c2e3b2fa8 100644 | |
--- a/test/test_utils.py | |
+++ b/test/test_utils.py | |
@@ -287,6 +287,10 @@ class TestDataLoader(TestCase): | |
def setUp(self): | |
self.dataset = torch.randn(5, 3, 3, 2) | |
self.batch_size = 3 | |
+ fullname = self.id().lower() | |
+ is_cuda_test = 'gpu' in fullname or 'cuda' in fullname or 'cuda' in torch.tensor([]).device.type | |
+ if not is_cuda_test: | |
+ raise unittest.SkipTest("Test is probably not a CUDA test. Skipping to save time.") | |
def test_random_seed(self): | |
def run(): |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment