|
838 | 838 | * Solve any general-purpose issues that come up with Clad during the process.
|
839 | 839 | * Prepare demos and carry out development needed for lossy compression.
|
840 | 840 |
|
| 841 | +- name: "Add support for consteval and constexpr functions in clad" |
| 842 | + description: | |
| 843 | + In mathematics and computer algebra, automatic differentiation (AD) is |
| 844 | + a set of techniques to numerically evaluate the derivative of a function |
| 845 | + specified by a computer program. Automatic differentiation is an alternative |
| 846 | + technique to Symbolic differentiation and Numerical differentiation (the |
| 847 | + method of finite differences). Clad is based on Clang which provides the |
| 848 | + necessary facilities for code transformation. The AD library can differentiate |
| 849 | + non-trivial functions, to find a partial derivative for trivial cases and has |
| 850 | + good unit test coverage. |
| 851 | +
|
| 852 | + C++ provides the specifiers consteval and constexpr to allow compile time evaluation |
| 853 | + of functions. `constexpr` declares a possibility, i.e the function will be |
| 854 | + evaluated at compile time if possible, else at runtime; whereas `consteval` makes it |
| 855 | + mandatory, i.e every call to the function must produce a compile-time constant. |
| 856 | +
|
| 857 | + The aim of this project is to ensure that same semantics are followed by the generated |
| 858 | + derivative function, i.e if the primal function is evaluated at compile time |
| 859 | + (because of constexpr or consteval specifier), then the generated derivative code |
| 860 | + should also have the same specifier to be evaluatable at compile time. |
| 861 | +
|
| 862 | + This will enable clad to demonstrate the benefits of doing automatic differentiation |
| 863 | + directly on C++ frontend to utilize the benefits of clang's infrastructure. |
| 864 | +
|
| 865 | + After successful completion of the project the code snippet should work |
| 866 | + as expected: |
| 867 | + ```cpp |
| 868 | + #include <cstdio> |
| 869 | + #include "clad/Differentiator/Differentiator.h" |
| 870 | + |
| 871 | + constexpr double sq(double x) { return x*x; } |
| 872 | +
|
| 873 | + consteval double fn(double x, double y, double z) { |
| 874 | + double res = sq(x) + sq(y) + sq(z); |
| 875 | + return res; |
| 876 | + } |
| 877 | +
|
| 878 | + int main() { |
| 879 | + auto d_fn = clad::gradient(fn); |
| 880 | + double dx = 0, dy = 0, dz = 0; |
| 881 | + d_fn.execute(3, 4, 5, &dx, &dy, &dz); |
| 882 | + printf("Gradient vector: [%.2f, %.2f, %.2f]", dx, dy, dz); |
| 883 | + return 0; |
| 884 | + } |
| 885 | + ``` |
| 886 | + tasks: | |
| 887 | + The project consists of the following tasks: |
| 888 | + * Add support for differentiation with respect to consteval and constexpr |
| 889 | + functions in the forward mode. |
| 890 | + * Add support for differentiation with respect to consteval and constexpr |
| 891 | + functions in the reverse mode. |
| 892 | + * Extend the unit test coverage. |
| 893 | + * Develop tutorials and documentation. |
| 894 | + * Present the work at the relevant meetings and conferences. |
| 895 | +
|
841 | 896 | - name: "Improve robustness of dictionary to module lookups in ROOT"
|
842 | 897 | description: |
|
843 | 898 | The LHC smashes groups of protons together at close to the speed of light:
|
|
0 commit comments