-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added _get_device in config/_device.py for the default device (…
…see #524) refactor: rearranged methods in Image
- Loading branch information
1 parent
e2234b1
commit b30af81
Showing
5 changed files
with
48 additions
and
31 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"""Configuration for Safe-DS""" | ||
|
||
from ._device import _get_device | ||
|
||
__all__ = [ | ||
"_get_device", | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import torch | ||
from torch.types import Device | ||
|
||
|
||
def _get_device() -> Device: | ||
return torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu") |
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
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import torch | ||
|
||
from safeds.config import _get_device | ||
|
||
|
||
def test_device() -> None: | ||
if torch.cuda.is_available(): | ||
assert _get_device() == torch.device('cuda') | ||
else: | ||
assert _get_device() == torch.device('cpu') |