Skip to content

Commit

Permalink
fix tensor.real for earlier versions of PyTorch
Browse files Browse the repository at this point in the history
  • Loading branch information
rtqichen committed Apr 6, 2023
1 parent d6ee52b commit 64fbe9e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion torchdiffeq/_impl/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ def forward(self, t, y, *, perturb=Perturb.NONE):
# This dtype change here might be buggy.
# The exact time value should be determined inside the solver,
# but this can slightly change it due to numerical differences during casting.
t = t.real.to(y.abs().dtype)
if torch.is_complex(t):
t = t.real
t = t.to(y.abs().dtype)
if perturb is Perturb.NEXT:
# Replace with next smallest representable value.
t = _nextafter(t, t + 1)
Expand Down

0 comments on commit 64fbe9e

Please sign in to comment.