-
-
Notifications
You must be signed in to change notification settings - Fork 77
Open
Description
For defining rrules, I need to make use of the factorization in the forward pass. The rrules is also a linearsolve with the transpose of the linear system, how to avoid defining a new LinearProblem ?
This my current code, the LinearSolve interface with make it make use other algorithms and more clean
function ChainRulesCore.rrule(::typeof(efield), sim::Simulation,ϵ)
linsys = ConstructLinearSystem(sim, ϵ )
A ,b = linsys.A , linsys.b
x = similar(b); x_adj = similar(b)
F = lu(A)
LinearAlgebra.ldiv!(x, F, b)
sim.E = x
function efield_pullback(ȳ)
LinearAlgebra.ldiv!(x_adj, transpose(F), conj.(ȳ))
f̄ = NoTangent()
f̄oo = NoTangent()
ϵoo = real(x .* x_adj)
return f̄, f̄oo , ϵoo
end
return x, efield_pullback
end
Thanks!Metadata
Metadata
Assignees
Labels
No labels