Spaces:
Runtime error
Runtime error
Download modules/dml/device.py from bilegentile/test: direct link, hf CLI and curl.
- Browser
- Download file 422 Bytes
-
https://huggingface.co/spaces/bilegentile/test/resolve/refs%2Fpr%2F2/modules/dml/device.py
- Command line
-
hf download hf://spaces/bilegentile/test@refs/pr/2/modules/dml/device.py
-
curl -L -o device.py https://huggingface.co/spaces/bilegentile/test/resolve/refs%2Fpr%2F2/modules/dml/device.py
422 Bytes
| from typing import Optional | |
| import torch | |
| from .utils import rDevice, get_device | |
| class Device: | |
| def __enter__(self, device: Optional[rDevice]=None): | |
| torch.dml.context_device = get_device(device) | |
| def __init__(self, device: Optional[rDevice]=None) -> torch.device: # pylint: disable=return-in-init | |
| return get_device(device) | |
| def __exit__(self, t, v, tb): | |
| torch.dml.context_device = None | |