utils.py 366 Bytes
Newer Older
rusty1s's avatar
to csr  
rusty1s committed
1
2
import torch

3
4
dtypes = [torch.float, torch.double, torch.int, torch.long]
grad_dtypes = [torch.float, torch.double]
rusty1s's avatar
to csr  
rusty1s committed
5
6

devices = [torch.device('cpu')]
7
8
if torch.cuda.is_available():
    devices += [torch.device('cuda:{}'.format(torch.cuda.current_device()))]
rusty1s's avatar
to csr  
rusty1s committed
9
10


rusty1s's avatar
rusty1s committed
11
def tensor(x, dtype, device):
12
    return None if x is None else torch.tensor(x, dtype=dtype, device=device)