3 ms·
AST manipulation does not do it for AD in general (though XGrad.jl is doing it as a symbolic diff approach https://github.com/dfdx/XGrad.jl/ https://github.com/
by oxinabox 7y ago
AST manipulation does not do it for AD in general (though XGrad.jl is doing it as a symbolic diff approach https://github.com/dfdx/XGrad.jl/ https://github.com/dfdx/XGrad.jl/),
you want to work with the code reduced down to Single assignment form, and work with code blocks and the control flow graph.
for a number of reasons:
1. all control flow looks the same now (no 2 different kinds of loops + GOTOs)
2. one expression per line, no need to untangle larger experessions
3. Host of techniques from compiler world can come out to be used.
This is how Zgyote works, it used code that has been lowered into this form