Skip to content

Commit 1219098

Browse files
committed
added comment to explain check
1 parent 700f652 commit 1219098

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pytensor/tensor/rewriting/linalg.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def _find_solve_with_eye(node):
567567
def rewrite_inv_inv(fgraph, node):
568568
valid_inverses = (MatrixInverse, MatrixPinv, Solve, SolveTriangular)
569569
valid_solves = (Solve, SolveTriangular)
570-
# Check if Solve has b = eye
570+
# Check if its a valid inverse operation (either inv/pinv or if its solve, then b = eye)
571571
inv_check = False
572572
if hasattr(node.op, "core_op") and isinstance(node.op.core_op, valid_inverses):
573573
inv_check = True
@@ -580,7 +580,8 @@ def rewrite_inv_inv(fgraph, node):
580580
potential_inner_inv = node.inputs[0].owner
581581
if potential_inner_inv is None or potential_inner_inv.op is None:
582582
return None
583-
# Check if its an inner solve as well, does that have b = eye
583+
584+
# Check if its a valid inverse operation (either inv/pinv or if its solve, then b = eye)
584585
inv_check = False
585586
if hasattr(potential_inner_inv.op, "core_op") and isinstance(
586587
potential_inner_inv.op.core_op, valid_inverses

0 commit comments

Comments
 (0)