I just came across these two papers by Radul, Pearlmutter and Siskind and thought it would give food for thought particularly for LFortran.
On the subject of AD in Fortran, note that we have recently provided Fortran bindings for Enzyme - an automatic differentiation framework for LLVM and MLIR. An advantage of this approach is that, provided you make use of an LLVM-based compiler such as Flang or IFX, you can differentiate Fortran code with minimal source code changes, except to add in the calls to the differentiation routines. See Fortran Guide - Enzyme AD.
This is epic! I’ll try this out soon.
Any plans to support more recent Ifx versions?
@certik could this work for LFortran?
Can I use this for vector and matrix functions too? Or does it have to be scalar? For example to compute the Jacobian matrix df/dx where f and x are both vectors.
(Assuming your reply was to me.) We are mainly working with Flang for development and have provided some plugins for ease of use. The setup could certainly work for other IFX versions but we just haven’t set up CI jobs for those.
It is indeed possible to use LFortran - see
Yes, Enzyme works in the vector and matrix cases.