pub fn svd_rrule<T: Scalar>(
_tensor: &Tensor<T>,
_cotangent: &SvdCotangent<T>,
_options: Option<&SvdOptions>,
) -> AdResult<Tensor<T>>Expand description
Reverse-mode AD rule for SVD (VJP / pullback).
Computes the gradient of the input given cotangents for the SVD outputs.
Uses batched matrix operations (Mathieu 2019) that broadcast over *.
§Examples
ⓘ
use tenferro_linalg::{svd, svd_rrule, SvdCotangent};
use tenferro_tensor::{Tensor, MemoryOrder};
use tenferro_device::LogicalMemorySpace;
let col = MemoryOrder::ColumnMajor;
let mem = LogicalMemorySpace::MainMemory;
let a = Tensor::<f64>::zeros(&[3, 4], mem, col);
let cotangent = SvdCotangent {
u: None,
s: Some(Tensor::ones(&[3], mem, col)),
vt: None,
};
let grad_a = svd_rrule(&a, &cotangent, None).unwrap();