vgvassilev / clad

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

Add support for `[[clad::non_differentiable]]` in reverse mode #916

Open MihailMihov opened 1 month ago

MihailMihov commented 1 month ago

fixes #717

I've added the code for handing [[clad::non_differentiable]] that is already present in the forward mode visitor to the one for reverse mode. I also modified the tests from forward mode, but ReverseMode/NonDifferentiable.C is currently failing because of an issue with differentiating operator overloads in reverse mode.

github-actions[bot] commented 1 month ago

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

parth-07 commented 1 month ago

but ReverseMode/NonDifferentiable.C is currently failing because of an issue with differentiating operator overloads in reverse mode.

If we mark that operator overload as non-differentiable, then should the issue still happen?

MihailMihov commented 1 month ago

If we mark that operator overload as non-differentiable, then should the issue still happen?

I just tried changing the test and it still errors, but this time it is too many arguments to function call, expected 1, have 2, while if it tries to differentiate the operator it is too few arguments to function call, expected 4, have 3. I did open an issue for this and it is #917, where I put a more minimal failing test. I can try and look into the case where it fails when non-differentiable, but if I had to guess they are the same issue and fixing one would fix both cases.

parth-07 commented 1 month ago

but if I had to guess they are the same issue and fixing one would fix both cases.

Oh, yes, you are right. Thank you for the details.