-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Misc] Add a wrapper for torch.inference_mode (#6618)
- Loading branch information
1 parent
c9eef37
commit 42de2ce
Showing
5 changed files
with
49 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import Tuple | ||
|
||
import torch | ||
|
||
from .interface import Platform, PlatformEnum | ||
|
||
|
||
class TpuPlatform(Platform): | ||
_enum = PlatformEnum.TPU | ||
|
||
@staticmethod | ||
def get_device_capability(device_id: int = 0) -> Tuple[int, int]: | ||
raise RuntimeError("TPU does not have device capability.") | ||
|
||
@staticmethod | ||
def inference_mode(): | ||
return torch.no_grad() |
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