Skip to content

Commit ed314e5

Browse files
committed
fix test 2
1 parent e782774 commit ed314e5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

deepecho/models/basic_gan.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def __init__(
186186

187187
if enable_gpu:
188188
if sys.platform == 'darwin': # macOS
189-
if torch.backends.mps.is_available():
189+
if getattr(torch.backends, 'mps', None) and torch.backends.mps.is_available():
190190
device = torch.device('mps')
191191
else:
192192
device = torch.device('cpu')

tests/integration/test_basic_gan.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ def test__init___enable_gpu(self):
3333
model = BasicGANModel(epochs=10, enable_gpu=True)
3434

3535
# Assert
36-
if sys.platform == 'darwin' and torch.backends.mps.is_available():
36+
if (
37+
sys.platform == 'darwin'
38+
and getattr(torch.backends, 'mps', None)
39+
and torch.backends.mps.is_available()
40+
):
3741
expected_device = torch.device('mps')
3842
elif torch.cuda.is_available():
3943
expected_device = torch.device('cuda')

0 commit comments

Comments
 (0)