Skip to content
Open
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
5 changes: 4 additions & 1 deletion .github/scripts/ci_test_xpu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ pytest -v -s --ignore=torchao/test/quantization/pt2e/test_x86inductor_fusion.py
torchao/test/float8/ \
torchao/test/integration/test_integration.py \
torchao/test/prototype/ \
torchao/test/quantization/quantize_/workflows/
torchao/test/quantization/quantize_/workflows/ \
torchao/test/core/test_config.py \
torchao/test/test_model_architecture.py \
torchao/test/test_utils.py
16 changes: 8 additions & 8 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import torch
import torch.nn.functional as F

from torchao.testing.utils import skip_if_no_cuda
from torchao.utils import TorchAOBaseTensor, torch_version_at_least


Expand Down Expand Up @@ -128,14 +127,15 @@ def _test_default_impls_helper(self, lp_tensor, lp_tensor_for_copy):
self.assertTrue(torch.equal(lp_tensor.qdata, reconstructed.qdata))
self.assertEqual(lp_tensor.attr, reconstructed.attr)

device = torch.accelerator.current_accelerator()
# test _get_to_kwargs
_ = lp_tensor._get_to_kwargs(torch.strided, device="cuda")
_ = lp_tensor._get_to_kwargs(layout=torch.strided, device="cuda")
_ = lp_tensor._get_to_kwargs(torch.strided, device=device)
_ = lp_tensor._get_to_kwargs(layout=torch.strided, device=device)

# `to` / `_to_copy`
original_device = lp_tensor.device
lp_tensor = lp_tensor.to("cuda")
self.assertEqual(lp_tensor.device.type, "cuda")
lp_tensor = lp_tensor.to(device)
self.assertEqual(lp_tensor.device.type, device.type)
lp_tensor = lp_tensor.to(original_device)
self.assertEqual(lp_tensor.device, original_device)

Expand Down Expand Up @@ -218,7 +218,7 @@ def _test_default_impls_helper(self, lp_tensor, lp_tensor_for_copy):
getattr(lp_tensor, tensor_attribute_name),
)

@skip_if_no_cuda()
@unittest.skipIf(not torch.accelerator.is_available(), "Need CUDA available")
def test_default_impls(self):
"""Making sure some common functions has default implementations, such as
__tensor_unflatten__, __tensor_flatten__, _apply_fn_to_data, __repr__, to
Expand Down Expand Up @@ -248,7 +248,7 @@ def __init__(self, qdata, attr, device):
lp_tensor_for_copy = MyTensor(another_tensor, "attr", None)
self._test_default_impls_helper(lp_tensor, lp_tensor_for_copy)

@skip_if_no_cuda()
@unittest.skipIf(not torch.accelerator.is_available(), "Need GPU available")
def test_default_impls_with_optional_data(self):
class MyTensorWithOptionalData(TorchAOBaseTensor):
tensor_data_names = ["qdata"]
Expand Down Expand Up @@ -285,7 +285,7 @@ def __init__(self, qdata, attr, device, zero_point=None):
)
self._test_default_impls_helper(lp_tensor, lp_tensor_for_copy)

@skip_if_no_cuda()
@unittest.skipIf(not torch.accelerator.is_available(), "Need GPU available")
def test_default_impls_with_optional_attr(self):
class MyTensorWithOptionalData(TorchAOBaseTensor):
tensor_data_names = ["qdata"]
Expand Down
Loading