-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
163 additions
and
33 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
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
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
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
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
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
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
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,34 @@ | ||
import sys | ||
from typing import Any | ||
|
||
import lightning.pytorch as pl | ||
|
||
|
||
def _patch_sys_modules() -> None: | ||
self = sys.modules[__name__] | ||
sys.modules["lightning.pytorch.accelerators.xpu"] = self | ||
|
||
|
||
class XPUAccelerator: | ||
auto_device_count = ... | ||
get_parallel_devices = ... | ||
is_available = ... | ||
parse_devices = ... | ||
setup_device = ... | ||
teardown = ... | ||
|
||
def __init__(self, *_: Any, **__: Any) -> None: | ||
raise NotImplementedError( | ||
"The `XPUAccelerator` class has been moved to an external package." | ||
" Install the extension package as `pip install lightning-xpu`" | ||
" and import with `from lightning_xpu import XPUAccelerator`." | ||
" Please see: https://github.com/Lightning-AI/lightning-XPU for more details." | ||
) | ||
|
||
|
||
def _patch_classes() -> None: | ||
setattr(pl.accelerators, "XPUAccelerator", XPUAccelerator) | ||
|
||
|
||
_patch_sys_modules() | ||
_patch_classes() |
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
Oops, something went wrong.