Difference between `torch.dtype` and `torch.tensortype`


Recently I ran into an error when I tried to convert an array into float tensor using torch.tensor(arr, dtype=torch.FloatTensor).

TypeError: tensor(): argument 'dtype' must be torch.dtype, not torch.tensortype

I checked out the documentation here and it turns out I did not have correct understanding about data type. I previously thought torch.float is equivalent to torch.FloatTensor.

However, I still do not get the difference between those two and rationale behind this design, which appears to be redundant at first glimpse. Maybe torch.FloatTensor depends on particular storage type whereas torch.float doe not?


dtype is a datatype, like torch.float or torch.double
tensortype is a type of tensor, like torch.FloatTensor, torch.DoubleTensor.


This below two code does the same thing. You can either explicitly provide the datatype or use that type of tensor.

float_tensor = torch.tensor([4,5,6], dtype=torch.float)

float_tensor = torch.FloatTensor([4,5,6])