Skip to content

Commit e6af529

Browse files
committed
added comment to explain check
1 parent e6b6476 commit e6af529

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
@@ -597,7 +597,7 @@ def _find_solve_with_eye(node):
597597
def rewrite_inv_inv(fgraph, node):
598598
valid_inverses = (MatrixInverse, MatrixPinv, Solve, SolveTriangular)
599599
valid_solves = (Solve, SolveTriangular)
600-
# Check if Solve has b = eye
600+
# Check if its a valid inverse operation (either inv/pinv or if its solve, then b = eye)
601601
inv_check = False
602602
if hasattr(node.op, "core_op") and isinstance(node.op.core_op, valid_inverses):
603603
inv_check = True
@@ -610,7 +610,8 @@ def rewrite_inv_inv(fgraph, node):
610610
potential_inner_inv = node.inputs[0].owner
611611
if potential_inner_inv is None or potential_inner_inv.op is None:
612612
return None
613-
# Check if its an inner solve as well, does that have b = eye
613+
614+
# Check if its a valid inverse operation (either inv/pinv or if its solve, then b = eye)
614615
inv_check = False
615616
if hasattr(potential_inner_inv.op, "core_op") and isinstance(
616617
potential_inner_inv.op.core_op, valid_inverses

0 commit comments

Comments
 (0)