aliutkus / torchinterp1d

1D interpolation for pytorch
BSD 3-Clause "New" or "Revised" License
162 stars 19 forks source link

torch.float64 #4

Open tseep opened 5 years ago

tseep commented 5 years ago

Thank you for this nice package.

Example:

device = torch.device('cpu')
dtype = torch.float32

x_tensor = torch.linspace(0, 5, 1000, dtype=dtype).to(device)
y_tensor = torch.sin(x_tensor).to(device)
xq_tensor = torch.linspace(0, 5, 999, dtype=dtype).to(device)

yq_tensor = Interp1d()(x_tensor, y_tensor, xq_tensor, None)

It works nicely when dtype = torch.float32 but gives an error when dtype = torch.float64. Is this expected?

aliutkus commented 5 years ago

oups, I did not try float64, it should not make a big difference, probably some conversion to float in the code instead of something more flexible and data dependent. I'm sorry for this

cklb commented 5 years ago

Firstly, like tseep already said, thank you very much for this nice package.

As for the problem, I may have identified one of its causes in 486f50417fd75d3e0aff3db8e774cbda83d22f3a. However, the problem seems to lie in 'searchsorted_cpu_wrapper.cpp` where the identifier 'float' is mentioned quite often. Since I am new to the topic, I am not able to give further insight. Maybe the way torch itself handles these problems could provide some help?