Skip to content

Commit

Permalink
Support of preconditioners through adjoint()
Browse files Browse the repository at this point in the history
  • Loading branch information
michel2323 committed Apr 30, 2024
1 parent fc34100 commit 4c99ca3
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/EnzymeRules/enzymerules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,12 @@ for AMT in (:Matrix, :SparseMatrixCSC)
if verbose > 0
@info "($psolver, $pamt) reverse"
end
if M == I
nothing
elseif isa(M, IncompleteLU.ILUFactorization)
U = copy(M.U)
L = copy(M.L)
transpose!(U, M.L)
transpose!(L, M.U)
N = IncompleteLU.ILUFactorization(L, U)
M = I
else
error("Preconditioner not supported")
adjM = adjoint(N)
adjN = adjoint(M)
_b.dval .= Krylov.$solver(adjoint(A), bx[]; M=adjM, N=adjN, verbose=verbose, options...)[1]
if isa(_A, Duplicated)
_A.dval .= -x .* _b.dval'
end
_b.dval .= Krylov.$solver(adjoint(A), bx[]; M=M, N=N, verbose=verbose, options...)[1]
_A.dval .= -x .* _b.dval'
return (nothing, nothing)
end
end
Expand Down

0 comments on commit 4c99ca3

Please sign in to comment.