Skip to content

Commit

Permalink
make check for infinite eigenvalues more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
davidweichiang committed Sep 12, 2024
1 parent 7da3552 commit d526c3a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions fggs/semirings.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ def solve_thunks(self,
b = make_b()
try:
a.neg_().diagonal().add_(1)
x = torch.linalg.solve(a, b)
if torch.all(torch.copysign(torch.tensor(1.), x) > 0.): # catches -0.0
return x
if not torch.any(torch.isinf(a)):
x = torch.linalg.solve(a, b)
if torch.all(x >= 0.):
return x
except RuntimeError as e:
if '(Cannot allocate memory)' in str(e): raise
pass
Expand Down

0 comments on commit d526c3a

Please sign in to comment.