Repository navigation
Add reverse mode autodiff to the autodiff performance benchmark - #1670
reach2sayan wants to merge 2 commits into
Conversation
|
@NAThompson I was thinking of some speedups in reverse mode as well. The idea I wanna pitch is to try to The tape's blocks never move, and memory is freed only on clear(). So pointers into a block stay valid exactly as long as the iterators do. So instead of holding the 3 iterators, each node can just hold 3 plain pointers: to its adjoint, and to the start of its derivatives and arguments. That means a node's derivatives and arguments must each be one unbroken array, to be indexed through a pointer. A function say For the lookup, backward() can just find the block that holds the node's address (one check per block, not per node), then walk each block backwards through a plain pointer. This does put a bound on the node: one expression can have at most BOOST_MATH_BUFFER_SIZE (65536 by default) rvar operands. But I think its big enough. The tape itself stays unbounded. I could provide an initial implementation. |
…er the degree, MseGibbsEnergy<1>/<2> over the species, and the extended Rosenbrock functionover the number of variables.
Adds reverse mode autodiff (
rvar) toreporting/performance/autodiff_performance.cpp.TranscendentalReverse,InverseFunctionsReverse,TwoVariablesReverse,ThreeVariablesReverse,BlackScholesFourVariablesReverse: the gradient in every input (rdiff::grad).Benchmarks over a problem size:
HornerReverse: over the number of coefficients, 8 to 1024.MseGibbsEnergy<1>/MseGibbsEnergy<2>: the gradient / Hessian (rdiff::hess) in P over the number of species, 4 to 128.RosenbrockReverse<1>/RosenbrockReverse<2>: the extended Rosenbrock function of n variables, 8 to 1024 / 8 to 128. One sweep gives all n partials, so the gradient is O(n); the Hessian sweeps once per variable, so it is O(n²).