clad
clad copied to clipboard
clad -- automatic differentiation for C/C++
Test: ```cpp #include "clad/Differentiator/Differentiator.h" class SimpleFunctions1 { public: SimpleFunctions1() noexcept : x(0), y(0) {} SimpleFunctions1(double p_x, double p_y) noexcept : x(p_x), y(p_y) {} double x; double y; double mem_fn_1(double i,...
In reverse-mode AD, Clad generates forward pass functions (`_forw`) to facilitate correct differentiation of functions returning a pointer or a reference. For more information about forward pass functions, please refer...
In this case, the compilation fails: ```c++ #include "clad/Differentiator/Differentiator.h" #include namespace clad::custom_derivatives { template void use_functor_pushforward(double x, F& f, double d_x, F& d_f) { f.operator_call_pushforward(x, &d_f, d_x); } } template...
We support custom pullbacks for member functions, but there are no tests for it. We should add tests for the functionality.
```cpp double fn(double x, double y){ double g = 0; { double &j = x; g += j*j; } return g; } ``` generates: ```cpp void fn_grad(double x, double y,...
Differentiation of ```cpp double f(double x){ int v[] = {1, 2, 3}; double res = 0; for (auto n = v.size(); auto i : v){ res+=n; } return res; }...
Currently we have `BuiltinDerivatives.h` and `STLDerivatives.h`. In `BuiltinDerivatives` we mix stl functions and libc functions. We should split these into files: * BuiltinDerivatives.h -- contains only propagators for `__builtin_` functions...
```cpp #include "clad/Differentiator/Differentiator.h" #include double f(double x){ double sum = 0; std::vector a = {1, 2, 3}; for(auto& i: a){ sum+=i*x; } return sum; } int main(){ auto fdx =...
Currently, on master, we have two reverse diff modes: ``DiffMode::reverse`` for gradients and ``DiffMode::experimental_pullback`` for pullbacks. In this PR, they are essentially merged into ``DiffMode::reverse``. This has been achieved by...
Currently I have added a basic implementation of tape data structure with connected lists/slabs. It is more or less similar to current tape data strucutre I copied a lot of...