Last active
October 20, 2017 20:19
-
-
Save Kaixhin/8af7261dc790e8c899b4c2b2db97186e to your computer and use it in GitHub Desktop.
Device-agnostic PyTorch code
This file contains hidden or 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
import torch | |
def cast(cuda): | |
if cuda: | |
return lambda x: x.cuda() | |
else: | |
return lambda x: x | |
torch.cast = cast(False) | |
a = torch.cast(torch.rand(3, 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment