Does svd() not support forwarddiff?

The discussion @DanielVandH linked mentions GenericLinearAlgebra.jl, a project to implement linear algebra functions in pure Julia with support for generic arguments. The svd function from this package seems to work just fine with ForwardDiff:

using GenericLinearAlgebra: svd
using ForwardDiff

function f(x)
    a = [1 2; 3 4]
    a = a .* x
    _, s, _ = svd(a)
    return sum(s)
end

ForwardDiff.derivative(f,2)
# 5.830951894845303
1 Like