utils.py 401 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
import torch
from torch._tensor_docs import tensor_classes

rusty1s's avatar
rusty1s committed
4
tensors = [t[:-4] for t in tensor_classes]
rusty1s's avatar
rusty1s committed
5
tensors.remove('ShortTensor')  # TODO: PyTorch `atomicAdd` bug with short type.
rusty1s's avatar
rusty1s committed
6
7
tensors.remove('ByteTensor')  # We cannot properly test unsigned values.
tensors.remove('CharTensor')  # Overflow on gradient computations :(
rusty1s's avatar
rusty1s committed
8
9
10
11
12


def Tensor(str, x):
    tensor = getattr(torch, str)
    return tensor(x)