EnzymeAD / Enzyme.jl

Julia bindings for the Enzyme automatic differentiator
https://enzyme.mit.edu
MIT License
455 stars 64 forks source link

LAPACK Support (dtrtrs_64_) #241

Open enigne opened 2 years ago

enigne commented 2 years ago

I'm running this on julia 1.7.1, with a MacOS 12.2.1, it crashes

using Enzyme

function mybackslash!(x, A, b)
   x .= A \ b
   nothing
end

A = rand(5, 5)
b = rand(5, 1)
x = zeros(5, 1)

∂z_∂x = rand(size(x)...)
∂z_∂A = zero(A)
∂z_∂b = zero(b)

Enzyme.autodiff(mybackslash!, Const, Duplicated(x, ∂z_∂x), Duplicated(A, ∂z_∂A), Duplicated(b, ∂z_∂b))
luciano-drozda commented 2 years ago

I think support for BLAS is not yet there. So, for instance, matvec, matmul and algorithms for solving linear systems need to be explicitely coded, just as in the example here.

wsmoses commented 2 years ago

This is now an absence of lapack support.

However, julia no longer crashes.

wsmoses commented 1 year ago

If anyone here has cycles to add an EnzymeRule for this or other lapack functions, I'm sure it would be greatly appreciated. (one can look at existing chainrules and the enzyme.jl custom rules docs for inspiration)