Skip to content

Commit

Permalink
move to tests/ignite/__init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
leej3 committed May 21, 2024
1 parent 5aee3be commit 68c26a8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
11 changes: 11 additions & 0 deletions tests/ignite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,14 @@

def cpu_and_maybe_cuda():
return ("cpu",) + (("cuda",) if torch.cuda.is_available() else ())


def is_mps_available_and_functional():
if not torch.backends.mps.is_available():
return False
try:
# Try to allocate a small tensor on the MPS device
torch.tensor([1.0], device="mps")
return True
except RuntimeError:
return False
2 changes: 1 addition & 1 deletion tests/ignite/distributed/utils/test_serial.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import ignite.distributed as idist
from ignite.distributed.comp_models.base import _torch_version_le_112
from tests.ignite import is_mps_available_and_functional
from tests.ignite.distributed.utils import (
_sanity_check,
_test_distrib__get_max_length,
Expand All @@ -12,7 +13,6 @@
_test_distrib_new_group,
_test_sync,
)
from ....utils_for_tests import is_mps_available_and_functional


def test_no_distrib(capsys):
Expand Down
2 changes: 1 addition & 1 deletion tests/ignite/engine/test_create_supervised.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
)
from ignite.metrics import MeanSquaredError

from ...utils_for_tests import is_mps_available_and_functional # type: ignore
from tests.ignite import is_mps_available_and_functional


class DummyModel(torch.nn.Module):
Expand Down
12 changes: 0 additions & 12 deletions tests/utils_for_tests.py

This file was deleted.

0 comments on commit 68c26a8

Please sign in to comment.