In mathematics and computer algebra, automatic differentiation (AD) is a set of techniques to numerically evaluate the derivative of a function specified by a computer program. Automatic differentiation is an alternative technique to Symbolic differentiation and Numerical differentiation (the method of finite differences). Clad is based on Clang which provides the necessary facilities for code transformation. The AD library is able to differentiate non-trivial functions, to find a partial derivative for trivial cases and has good unit test coverage.
Vector mode support will facilitate the computation of gradients using the forward mode AD in a single pass and thus without explicitly performing differentiation n times for n function arguments. The major benefit of using vector mode is that computationally expensive operations do not need to be recomputed n times for n function arguments.
For example, if we want to compute df/dx
and df/dy
of a function
f(x, y)
using the forward mode AD in Clad, then currently we need to
explicitly differentiate f
two times. Vector mode will allow the generation of
f_d(x, y)
such that we will be able to get partial derivatives with respect to
all the function arguments (gradient) in a single call.
The project consists of the following tasks:
clad::differentiate
for
vector mode.C/C++, Clang, LLVM
After successful completion of the project the code snippet should work as expected:
#include <clad/Differentiator/Differentiator.h>
#include <iostream>
double someComputationalIntensiveFn();
double fn(double x, double y) {
double t = someComputationalIntensiveFn(); // should be computed only once
// in the derived function.
double res = 2 * t * x + 3 * t * x * y;
return t;
}
int main() {
auto d_fn = clad::differentiate(fn, "arr");
double d_x = 0, d_y = 0;
d_fn.execute(3, 5, &d_x, &d_y);
std::cout << "Derivative of fn wrt d_x: " << d_x << "\n";
std::cout << "Derivative of fn wrt d_y: " << d_y << "\n";
}
If you have interest in working on the project there is a list of things to do in order to maximize your chances to get selected:
The mentors are interested in working with all candidates but unfortunately the rules allow only one to be selected. There are a few tasks which give bonus points to candidate’s application:
Compiler-Research clad clang-repl llvm clang