inv_frule

Function inv_frule 

Source
pub fn inv_frule<T, C>(
    ctx: &mut C,
    tensor: &Tensor<T>,
    tangent: &Tensor<T>,
) -> AdResult<(Tensor<T>, Tensor<T>)>
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();