pub fn inv_frule<T, C>(
ctx: &mut C,
tensor: &Tensor<T>,
tangent: &Tensor<T>,
) -> AdResult<(Tensor<T>, Tensor<T>)>where
T: KernelLinalgScalar,
C: TensorLinalgContextFor<T> + TensorScalarContextFor<Standard<T>>,
C::Backend: 'static,
<C as TensorScalarContextFor<Standard<T>>>::ScalarBackend: 'static + TensorAnalyticPrims<Standard<T>, Context = C>,Expand description
Forward-mode AD rule for matrix inverse (JVP / pushforward).
ยงExamples
use tenferro_linalg::inv_frule;
use tenferro_prims::CpuContext;
use tenferro_tensor::{Tensor, MemoryOrder};
use tenferro_device::LogicalMemorySpace;
let col = MemoryOrder::ColumnMajor;
let mem = LogicalMemorySpace::MainMemory;
let mut ctx = CpuContext::new(1);
let a = Tensor::<f64>::eye(3, mem, col).unwrap();
let da = Tensor::<f64>::ones(&[3, 3], mem, col).unwrap();
let (a_inv, da_inv) = inv_frule(&mut ctx, &a, &da).unwrap();