L. Mann
L. Mann

Reputation: 143

Is there a way to use Enzyme.jl to auto-differentiate a matrix inverse?

I am new to auto-differentiation in Julia and have been trying to use Enzyme to compute the gradient of a custom function that involves a matrix inverse. I have come across the problem that Enzyme throws an error when differentiating the LinearAlgebra.inv function. For example, running

function f(M)
    return sum(inv(M))
end
x = rand(3,3)
Enzyme.gradient(Reverse, f, x)

yields

> ERROR: 
No augmented forward pass found for dgetrf_64_
 at context:   call void @dgetrf_64_(i8* noundef nonnull %8, i8* noundef nonnull %11, i64 %42, i8* noundef nonnull %14, i64 %46, i64 noundef %bitcast_coercion42) #82 [ "jl_roots"({} addrspace(10)* null, {} addrspace(10)* %39, {} addrspace(10)* null, {} addrspace(10)* %2, {} addrspace(10)* null, {} addrspace(10)* null) ], !dbg !147

What is the best way to deal with this problem?

PS: Zygote seems to be able to auto-differentiate LinearAlgebra.inv. However, I would prefer not to use Zygote as the restrictions on in-place modifications would require a major rewrite of the code which itself introduces new problems.

Upvotes: 0

Views: 68

Answers (0)

Related Questions