vgvassilev / clad

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

Add support for custom derivatives for top level derivatives #934

Closed vaithak closed 2 weeks ago

vaithak commented 3 weeks ago

fixes #352

vaithak commented 3 weeks ago

~This doesn't add support with vector mode; I am trying to debug it and will add a follow-up PR.~ It works now πŸ‘πŸΌ

codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 99.15254% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.80%. Comparing base (db0a949) to head (900f21d). Report is 2 commits behind head on master.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/vgvassilev/clad/pull/934/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/934?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 #934 +/- ## ========================================== + Coverage 93.72% 93.80% +0.07% ========================================== Files 54 55 +1 Lines 7781 7810 +29 ========================================== + Hits 7293 7326 +33 + Misses 488 484 -4 ``` | [Files](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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/DerivativeBuilder.h](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDerivativeBuilder.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0Rlcml2YXRpdmVCdWlsZGVyLmg=) | `100.00% <ΓΈ> (ΓΈ)` | | | [include/clad/Differentiator/DerivedFnCollector.h](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDerivedFnCollector.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0Rlcml2ZWRGbkNvbGxlY3Rvci5o) | `100.00% <ΓΈ> (ΓΈ)` | | | [include/clad/Differentiator/DynamicGraph.h](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDynamicGraph.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0R5bmFtaWNHcmFwaC5o) | `98.14% <100.00%> (+0.07%)` | :arrow_up: | | [include/clad/Differentiator/HessianModeVisitor.h](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FHessianModeVisitor.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0hlc3NpYW5Nb2RlVmlzaXRvci5o) | `100.00% <ΓΈ> (ΓΈ)` | | | [lib/Differentiator/BaseForwardModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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.93% <100.00%> (-0.01%)` | :arrow_down: | | [lib/Differentiator/CladUtils.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=lib%2FDifferentiator%2FCladUtils.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0NsYWRVdGlscy5jcHA=) | `93.36% <100.00%> (+0.50%)` | :arrow_up: | | [lib/Differentiator/DerivativeBuilder.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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/DerivedFnCollector.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=lib%2FDifferentiator%2FDerivedFnCollector.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0Rlcml2ZWRGbkNvbGxlY3Rvci5jcHA=) | `100.00% <100.00%> (ΓΈ)` | | | [lib/Differentiator/HessianModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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.46% <100.00%> (-0.03%)` | :arrow_down: | | [lib/Differentiator/ReverseModeForwPassVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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%> (ΓΈ)` | | | ... and [3 more](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/vgvassilev/clad/pull/934/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | [Files](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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/DerivativeBuilder.h](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDerivativeBuilder.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0Rlcml2YXRpdmVCdWlsZGVyLmg=) | `100.00% <ΓΈ> (ΓΈ)` | | | [include/clad/Differentiator/DerivedFnCollector.h](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDerivedFnCollector.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0Rlcml2ZWRGbkNvbGxlY3Rvci5o) | `100.00% <ΓΈ> (ΓΈ)` | | | [include/clad/Differentiator/DynamicGraph.h](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FDynamicGraph.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0R5bmFtaWNHcmFwaC5o) | `98.14% <100.00%> (+0.07%)` | :arrow_up: | | [include/clad/Differentiator/HessianModeVisitor.h](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=include%2Fclad%2FDifferentiator%2FHessianModeVisitor.h&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-aW5jbHVkZS9jbGFkL0RpZmZlcmVudGlhdG9yL0hlc3NpYW5Nb2RlVmlzaXRvci5o) | `100.00% <ΓΈ> (ΓΈ)` | | | [lib/Differentiator/BaseForwardModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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.93% <100.00%> (-0.01%)` | :arrow_down: | | [lib/Differentiator/CladUtils.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=lib%2FDifferentiator%2FCladUtils.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0NsYWRVdGlscy5jcHA=) | `93.36% <100.00%> (+0.50%)` | :arrow_up: | | [lib/Differentiator/DerivativeBuilder.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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/DerivedFnCollector.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree&filepath=lib%2FDifferentiator%2FDerivedFnCollector.cpp&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev#diff-bGliL0RpZmZlcmVudGlhdG9yL0Rlcml2ZWRGbkNvbGxlY3Rvci5jcHA=) | `100.00% <100.00%> (ΓΈ)` | | | [lib/Differentiator/HessianModeVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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.46% <100.00%> (-0.03%)` | :arrow_down: | | [lib/Differentiator/ReverseModeForwPassVisitor.cpp](https://app.codecov.io/gh/vgvassilev/clad/pull/934?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%> (ΓΈ)` | | | ... and [3 more](https://app.codecov.io/gh/vgvassilev/clad/pull/934?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev) | | ... and [1 file with indirect coverage changes](https://app.codecov.io/gh/vgvassilev/clad/pull/934/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Vassil+Vassilev)
vaithak commented 3 weeks ago

Everything is passing now πŸ‘πŸΌ

github-actions[bot] commented 3 weeks ago

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

vaithak commented 3 weeks ago

Added vector mode support in a new commit, it works πŸ‘πŸΌ

github-actions[bot] commented 3 weeks ago

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

vaithak commented 3 weeks ago

LGTM! Is this ready to be merged as it looks like you are pushing more code to it?

Ready to go. The latest commit was just for vector mode, it works in the same way as all other visitors. I earlier thought it would take more effort. Good to be merged πŸ‘πŸΌ