vgvassilev / clad

clad -- automatic differentiation for C/C++
GNU Lesser General Public License v3.0
266 stars 113 forks source link

Add support for computing only the diagonal hessian entries #950

Closed vaithak closed 1 week ago

vaithak commented 2 weeks ago

fixes #509

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 97.53086% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.83%. Comparing base (e37264d) to head (48695ac).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/vgvassilev/clad/pull/950/graphs/tree.svg?width=650&height=150&src=pr&token=9f6Q4em8hE&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev)](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) ```diff @@ Coverage Diff @@ ## master #950 +/- ## ========================================== + Coverage 93.81% 93.83% +0.01% ========================================== Files 55 55 Lines 7831 7878 +47 ========================================== + Hits 7347 7392 +45 - Misses 484 486 +2 ``` | [Files](https://app.codecov.io/gh/vgvassilev/clad/pull/950?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | Coverage Δ | | |---|---|---| | [include/clad/Differentiator/CladConfig.h](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FCladConfig.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0NsYWRDb25maWcuaA==) | `100.00% <ø> (ø)` | | | [include/clad/Differentiator/DiffPlanner.h](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDiffPlanner.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0RpZmZQbGFubmVyLmg=) | `68.18% <ø> (ø)` | | | [lib/Differentiator/BaseForwardModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FBaseForwardModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0Jhc2VGb3J3YXJkTW9kZVZpc2l0b3IuY3Bw) | `98.95% <100.00%> (+<0.01%)` | :arrow_up: | | [lib/Differentiator/DerivativeBuilder.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FDerivativeBuilder.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0Rlcml2YXRpdmVCdWlsZGVyLmNwcA==) | `100.00% <100.00%> (ø)` | | | [lib/Differentiator/DiffPlanner.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FDiffPlanner.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0RpZmZQbGFubmVyLmNwcA==) | `98.66% <100.00%> (+0.02%)` | :arrow_up: | | [lib/Differentiator/HessianModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FHessianModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0hlc3NpYW5Nb2RlVmlzaXRvci5jcHA=) | `99.53% <100.00%> (+0.07%)` | :arrow_up: | | [lib/Differentiator/ReverseModeForwPassVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FReverseModeForwPassVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL1JldmVyc2VNb2RlRm9yd1Bhc3NWaXNpdG9yLmNwcA==) | `100.00% <100.00%> (ø)` | | | [lib/Differentiator/ReverseModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FReverseModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL1JldmVyc2VNb2RlVmlzaXRvci5jcHA=) | `97.25% <100.00%> (+<0.01%)` | :arrow_up: | | [tools/ClangPlugin.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=tools%2FClangPlugin.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-dG9vbHMvQ2xhbmdQbHVnaW4uY3Bw) | `95.58% <100.00%> (+0.02%)` | :arrow_up: | | [include/clad/Differentiator/DiffMode.h](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDiffMode.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0RpZmZNb2RlLmg=) | `0.00% <0.00%> (ø)` | | | [Files](https://app.codecov.io/gh/vgvassilev/clad/pull/950?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | Coverage Δ | | |---|---|---| | [include/clad/Differentiator/CladConfig.h](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FCladConfig.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0NsYWRDb25maWcuaA==) | `100.00% <ø> (ø)` | | | [include/clad/Differentiator/DiffPlanner.h](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDiffPlanner.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0RpZmZQbGFubmVyLmg=) | `68.18% <ø> (ø)` | | | [lib/Differentiator/BaseForwardModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FBaseForwardModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0Jhc2VGb3J3YXJkTW9kZVZpc2l0b3IuY3Bw) | `98.95% <100.00%> (+<0.01%)` | :arrow_up: | | [lib/Differentiator/DerivativeBuilder.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FDerivativeBuilder.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0Rlcml2YXRpdmVCdWlsZGVyLmNwcA==) | `100.00% <100.00%> (ø)` | | | [lib/Differentiator/DiffPlanner.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FDiffPlanner.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0RpZmZQbGFubmVyLmNwcA==) | `98.66% <100.00%> (+0.02%)` | :arrow_up: | | [lib/Differentiator/HessianModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FHessianModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0hlc3NpYW5Nb2RlVmlzaXRvci5jcHA=) | `99.53% <100.00%> (+0.07%)` | :arrow_up: | | [lib/Differentiator/ReverseModeForwPassVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FReverseModeForwPassVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL1JldmVyc2VNb2RlRm9yd1Bhc3NWaXNpdG9yLmNwcA==) | `100.00% <100.00%> (ø)` | | | [lib/Differentiator/ReverseModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=lib%2FDifferentiator%2FReverseModeVisitor.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL1JldmVyc2VNb2RlVmlzaXRvci5jcHA=) | `97.25% <100.00%> (+<0.01%)` | :arrow_up: | | [tools/ClangPlugin.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=tools%2FClangPlugin.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-dG9vbHMvQ2xhbmdQbHVnaW4uY3Bw) | `95.58% <100.00%> (+0.02%)` | :arrow_up: | | [include/clad/Differentiator/DiffMode.h](https://app.codecov.io/gh/vgvassilev/clad/pull/950?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDiffMode.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0RpZmZNb2RlLmg=) | `0.00% <0.00%> (ø)` | |
github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

vaithak commented 2 weeks ago

I think this is heading in a good direction. I am a bit worried that we switched from running forward and reverse to running forward twice for the diagonal only. I suspect the reason is our plan to try vector mode, but is there something else? Is there any point in making how we create the hessian configurable?

The main issue is that reverse mode currently generates a void function, which cannot be easily differentiated by any of the modes. Thus, it is beneficial to start with a forward mode for now. The second one can be anything. Similar will be true for vector mode too, and that will be a challenge to fix / make it work. So, currently, we should refrain from providing the sequence of modes as configurable.

github-actions[bot] commented 2 weeks ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 1 week ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 1 week ago

clang-tidy review says "All clean, LGTM! :+1:"

github-actions[bot] commented 1 week ago

clang-tidy review says "All clean, LGTM! :+1:"