Automatic Type Casting

Hi, I recently find that torch.Tensor will automatically cast the input numpy.ndarray to the float type. And I am wondering if there are anyway to bypass this.

For example:

import numpy as np, torch

a = np.arange(5).astype(np.int32)
b = torch.Tensor(a)

Then the tensor b here will automatically get the type float. I am aware that using will cast b into int, but I am wondering if there are any ways to avoid this by some mechanisms in torch.Tensor.

Thank you!

Never mind, I just found that torch.tensor can solve this.