testing.py 655 Bytes
Newer Older
1
2
from typing import Any

rusty1s's avatar
to csr  
rusty1s committed
3
import torch
YanbingJiang's avatar
YanbingJiang committed
4
5
import torch_scatter
from packaging import version
rusty1s's avatar
to csr  
rusty1s committed
6

rusty1s's avatar
rusty1s committed
7
8
reductions = ['sum', 'add', 'mean', 'min', 'max']

rusty1s's avatar
rusty1s committed
9
10
dtypes = [torch.half, torch.float, torch.double, torch.int, torch.long]
grad_dtypes = [torch.half, torch.float, torch.double]
rusty1s's avatar
to csr  
rusty1s committed
11

YanbingJiang's avatar
YanbingJiang committed
12
13
14
15
if version.parse(torch_scatter.__version__) > version.parse("2.0.9"):
    dtypes.append(torch.bfloat16)
    grad_dtypes.append(torch.bfloat16)

rusty1s's avatar
to csr  
rusty1s committed
16
devices = [torch.device('cpu')]
17
if torch.cuda.is_available():
18
    devices += [torch.device('cuda:0')]
rusty1s's avatar
to csr  
rusty1s committed
19
20


21
def tensor(x: Any, dtype: torch.dtype, device: torch.device):
22
    return None if x is None else torch.tensor(x, dtype=dtype, device=device)