svd_frule

Function svd_frule 

Source
pub fn svd_frule<T, C>(
    ctx: &mut C,
    tensor: &Tensor<T>,
    tangent: &Tensor<T>,
    options: Option<&SvdOptions>,
) -> AdResult<(SvdResult<T, <T as LinalgScalar>::Real>, SvdResult<T, <T as LinalgScalar>::Real>)>
Expand description

Forward-mode AD rule for SVD (JVP / pushforward).

Computes the JVP of all SVD outputs given a tangent for the input. Uses batched matrix operations that broadcast over *.

ยงExamples

use tenferro_linalg::svd_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>::zeros(&[3, 4], mem, col).unwrap();
let da = Tensor::<f64>::ones(&[3, 4], mem, col).unwrap();
let (result, dresult) = svd_frule(&mut ctx, &a, &da, None).unwrap();