Skip to content

Commit

Permalink
Assume rank deficiency when traced matrix values are jit-compiled
Browse files Browse the repository at this point in the history
  • Loading branch information
holl- committed Jul 13, 2024
1 parent 2c83470 commit b768de5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions phiml/math/_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,13 @@ def min_rank_deficiency(self) -> Tensor:
hi = -max(shifts) or None
trimming_dict[dim] = slice(lo, hi)
trimmed_vals = [v[trimming_dict] for v in self.val.values()]
stencil_sum = sum(trimmed_vals)
stencil_abs = sum([abs(v) for v in trimmed_vals])
eps = {16: 1e-2, 32: 1e-5, 64: 1e-10}[get_precision()]
balanced_stencil = math.close(0, stencil_sum, rel_tolerance=0, abs_tolerance=eps * math.mean(stencil_abs), reduce=pattern_dim_names(self))
if all(v.available for v in trimmed_vals):
stencil_sum = sum(trimmed_vals)
stencil_abs = sum([abs(v) for v in trimmed_vals])
eps = {16: 1e-2, 32: 1e-5, 64: 1e-10}[get_precision()]
balanced_stencil = math.close(0, stencil_sum, rel_tolerance=0, abs_tolerance=eps * math.mean(stencil_abs), reduce=pattern_dim_names(self))
else:
balanced_stencil = True # cannot be determined here because values can vary. Assume could be rank-deficient to print warning
deficiency = 0
for shift, nonzero in self._nz_edge.items():
if shift and nonzero:
Expand Down

0 comments on commit b768de5

Please sign in to comment.