pub fn solve_frule<T: KernelLinalgScalar, C>(
ctx: &mut C,
a: &Tensor<T>,
b: &Tensor<T>,
tangent_a: &Tensor<T>,
tangent_b: &Tensor<T>,
) -> AdResult<(Tensor<T>, Tensor<T>)>where
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 linear solve (JVP / pushforward).
ยงExamples
use tenferro_linalg::solve_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 b = Tensor::<f64>::ones(&[3], mem, col).unwrap();
let da = Tensor::<f64>::ones(&[3, 3], mem, col).unwrap();
let db = Tensor::<f64>::ones(&[3], mem, col).unwrap();
let (x, dx) = solve_frule(&mut ctx, &a, &b, &da, &db).unwrap();