-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SplinePotential device compatibility #138
Conversation
…sses on different devices.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @E-Rum. I left some cosmetic comments and a question.
tests/test_potentials.py
Outdated
|
||
smearing = 1.0 | ||
exponent = 1.0 | ||
dtype = torch.float64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also parametrize over the dtype
?
src/torchpme/potentials/spline.py
Outdated
@@ -108,12 +115,16 @@ def __init__( | |||
self._krn_spline = CubicSpline(k_grid**2, yhat_grid) | |||
|
|||
if y_at_zero is None: | |||
self._y_at_zero = self._spline(torch.tensor([0.0])) | |||
self._y_at_zero = self._spline( | |||
torch.tensor([0.0], dtype=dtype, device=device) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not really matter, but looks cleaner to me. Feel free to ignore.
torch.tensor([0.0], dtype=dtype, device=device) | |
torch.zeros(1), dtype=dtype, device=device) |
src/torchpme/potentials/spline.py
Outdated
else: | ||
self._y_at_zero = y_at_zero | ||
|
||
if yhat_at_zero is None: | ||
self._yhat_at_zero = self._krn_spline(torch.tensor([0.0])) | ||
self._yhat_at_zero = self._krn_spline( | ||
torch.tensor([0.0], dtype=dtype, device=device) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
torch.tensor([0.0], dtype=dtype, device=device) | |
torch.zeros(1, dtype=dtype, device=device) |
And could you update |
Co-authored-by: Philip Loche <philip.loche@posteo.de>
Okay, I resolved the comments left by @PicoCentauri. If everything is alright and we decide to address the remaining issues in the next PR, we can proceed with the merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR addresses issue #137. It fixes the compatibility of the SplinePotential class with GPU. Additionally, it adds a new test to verify the compatibility between the Potential class and the output device.
📚 Documentation preview 📚: https://torch-pme--138.org.readthedocs.build/en/138/