Skip to content

Commit

Permalink
skip unit test if no cuda
Browse files Browse the repository at this point in the history
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:
  • Loading branch information
weifengpy committed Apr 28, 2024
1 parent 8926ee1 commit 6f834ce
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/dtypes/test_nf4.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,17 @@ def test_tensor_as_strided_invalid(self, input_size: Union[Tuple[int], int]):
stride = (nf4_tensor.stride()[1], nf4_tensor.stride()[0])
torch.as_strided(nf4_tensor, nf4_tensor.size(), stride, nf4_tensor.storage_offset())

@unittest.skipIf(not torch.cuda.is_available(), "Need CUDA available")
def test_pin_memory(self):
nf4_tensor = to_nf4(torch.randn(512 * 512))
self.assertFalse(nf4_tensor.is_pinned())

nf4_tensor = nf4_tensor.pin_memory()
self.assertTrue(nf4_tensor.is_pinned())

if torch.cuda.is_available():
nf4_tensor = to_nf4(torch.randn(512 * 512, device='cuda'))
self.assertFalse(nf4_tensor.is_pinned())
nf4_tensor = to_nf4(torch.randn(512 * 512, device='cuda'))
self.assertFalse(nf4_tensor.is_pinned())


@unittest.skipIf(not torch.cuda.is_available(), "Need CUDA available")
def test_to_cuda(self):
Expand Down

0 comments on commit 6f834ce

Please sign in to comment.