Python wrappers
Public Python APIs implemented by this engine symbol.Autograd node for the matrix inverse .
The forward result is captured in saved_output_;
no input is saved because the closed-form gradient only requires
. This trades a single matrix-shaped retain (peak memory) for
avoiding a second LU factorisation during backward.
Math
Shape
A:(..., N, N).B = A^{-1}: same shape asA.grad_out: same shape asA.
References
Giles, "Collected Matrix Derivative Results for Forward and Reverse Mode Algorithmic Differentiation" (Oxford NA-08/01, 2008), §2.2.3. Petersen & Pedersen, The Matrix Cookbook (2012), §9.1.3.
Attributes
schema_ v1OpSchema"inv", one input, AmpPolicy::KeepInput so mixed-precision training does not silently downcast the saved inverse.saved_ output_StorageStorage of the forward result retained for the backward.
Notes
- For very large matrices in deep graphs, holding alive until backward increases peak memory; users wishing to trade memory for compute would need to recompute the inverse (not currently supported here).
- Implementation uses
matmul_op+neg_opso second-order gradients flow through automatically.
Instance methods
2Compute the gradient {∂L/∂A} from the upstream gradient.
Parameters
grad_ outStorageUpstream gradient matching the forward output shape.
Returns
std::vector<Storage>Single-entry vector {∂L/∂A} aligned with the one differentiable input slot.
The same -B^T G B^T, recorded, with B = A^-1 recomputed from A.