-
Notifications
You must be signed in to change notification settings - Fork 122
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
Calling templated functions inside function doesn't work in backwards mode #1125
Comments
I am unable to reproduce this issue. I tried to reproduce it outside the ROOT environment. #include "clad/Differentiator/Differentiator.h"
#include <iostream>
#define show(x) std::cout<< #x << ": " << x << "\n";
template <class T>
inline double foo(double *params) { return params[0]; }
inline double bar(double *params) { return params[0]; }
double wrapper(double *params)
{
return foo<int>(params); // doesn't work!
// return bar(params); // works!
}
int main() {
auto wrapper_grad = clad::gradient(wrapper, "params");
std::vector<double> params(1, 0), d_params(1, 0);
wrapper_grad.execute(params.data(), d_params.data());
show(d_params[0]);
} This outputs: Can you please tell which Clad version are you using? |
Oh that is surprising. I'm using ROOT I also converted your smaller reproducer to a ROOT macro, by replacing the You have a ROOT build at hand to try this out too? I'll also try it with building Clad standalone. |
This is surprising indeed.
Unfortunately, I do not have a root build handy. I will try building ROOT and reproducing the issue.. |
I am assuming that |
Yes, that was a typo, sorry! I copy pasted from your post, instead of from my terminal output! |
@parth-07, ROOT has not moved to clang-repl and still does not really use the delay-until-end-of-tu logic. Maybe that’s the difference. @guitargeek what error do you get? |
Reproducer as a ROOT macro:
Output:
I could work around this limitation in RooFit by avoiding template functions in the generated code, but at some point it becomes unavoidable if we want to use functors as parameters.
This follows up on the following issue:
If this works, this would finally enable us to use more accurate routines for numeric integration that take function parameters, closing the gap between RooFit AD and regular RooFit.
The text was updated successfully, but these errors were encountered: