Skip to content
class

LUSolveBackward

LUSolveBackward

Autograd node for X=A−1BX = A^{-1} B with A=PLUA = P L U given packed as LU, wired on the aligned (batch, n, n) factor and (batch, n, k) right-hand side. The pivots are an integer input with no gradient and are held in pivots_.

With G=∂L/∂XG = \partial L / \partial X and Y=U−⊤GY = U^{-\top} G:

∂L∂B=A−⊤G=P L−⊤Y,R=−YX⊤, \frac{\partial L}{\partial B} = A^{-\top} G = P\, L^{-\top} Y, \qquad R = -Y X^\top, ∂L∂LU=triu(R)+tril ⁣(L−⊤R U⊤,−1), \frac{\partial L}{\partial \mathrm{LU}} = \mathrm{triu}(R) + \mathrm{tril}\!\left(L^{-\top} R\, U^\top, -1\right),

the upper part being ∂L/∂U\partial L / \partial U and the strict lower part ∂L/∂L\partial L / \partial L (the unit diagonal of LL is not stored). Every step is a recorded triangular solve or product, so the result differentiates again.

Methods

5
fn

apply_for_graph

int apply_for_graph(const int & grad_out)
fnconst

for_each_owned_tensor

void for_each_owned_tensor(const int & fn)
fn

release_own_saved

void release_own_saved()
fn

validate_versions

void validate_versions()

LU and B as every node guards its saved inputs, and the pivots. B stays guarded although the eager formula reads the saved solution instead: graph-mode backward recomputes X from it.