Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing num-diff fallback warnings in nested function calls #682

Open
guitargeek opened this issue Dec 13, 2023 · 0 comments
Open

Missing num-diff fallback warnings in nested function calls #682

guitargeek opened this issue Dec 13, 2023 · 0 comments

Comments

@guitargeek
Copy link
Contributor

Reproducer:

// Compile with clang++ -std=c++20 -fplugin=/usr/lib/clad.so missing_warning.cxx -o missing_warning

#include "clad/Differentiator/Differentiator.h"

#include <cmath>

inline double innerWrapper(double x)
{
   return std::lgamma(x); // call any function that needs num. diff.
}

double wrapper(double *params)
{
   // When calling the num-diffed function directly, you get the correct
   // warning:
   // return std::lgamma(params[0]);
   return innerWrapper(params[0]);
}

int main()
{
   auto grad = clad::gradient(wrapper, "params");
}

When calling std::lgamma directly, you get this correct warning when compiling:

warning: Falling back to numerical differentiation for 'lgamma' since no suitable overload was found and clad could not derive it. To disable this feature, compile your programs with -DCLAD_NO_NUM_DIFF.
1 warning generated.

However, the warning is absent in the reproducer with the nested function call.

It would be nice if you also get the warning in that situation, because these warnings are very useful to spot residual num. diffs in the gradients.

@guitargeek guitargeek changed the title Missing num-diff fallback warnings in nested funciton calls Missing num-diff fallback warnings in nested function calls Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant