You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simply adding a dummy loop with one iteration breaks certain gradients.
These minimal conditions are required to reproduce the problem:
A loop
Some "repacking" parameters from an array in a new array (commonly done in RooFit when forwarding subsets of parameters)
Doing some calculations with the repacked parameters in another function
My setup: Arch Linux with Clad master and clang 16.06.
I hope this problem can be fixed, as right now it is blocking me from implementing numeric integration routines in RooFit (similar to the reproducer, but the loop is not trivial).
Reproducer:
// Compile with clang++ -std=c++11 -fplugin=/usr/lib/clad.so cladIssue.cxx -o cladIssue// Add the -DFIXED to see the fixed version
#include"clad/Differentiator/Differentiator.h"
#include<iostream>
#include<vector>doublefunc(double *params)
{
return1.0 / (params[0] * params[0]);
}
doublewrapper(double *params)
{
double out = 0.0;
#ifndef FIXED
for (std::size_t i = 0; i < 1; ++i)
#else
#endif
{
double paramsPrime[] = {params[0]};
out = out + func(paramsPrime);
}
return out;
}
intmain()
{
auto grad = clad::gradient(wrapper, "params");
double x = 2.0;
double result = 0.0;
grad.execute(&x, &result);
std::cout << result << std::endl;
}
The text was updated successfully, but these errors were encountered:
Hi @guitargeek,
There was an issue in the code generated for for-loops containing a function call with an array as a parameter.
I have verified that the above code works after the fix proposed in #640.
Simply adding a dummy loop with one iteration breaks certain gradients.
These minimal conditions are required to reproduce the problem:
My setup: Arch Linux with
Clad
master and clang 16.06.I hope this problem can be fixed, as right now it is blocking me from implementing numeric integration routines in RooFit (similar to the reproducer, but the loop is not trivial).
Reproducer:
The text was updated successfully, but these errors were encountered: