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

Crash when differentiating some std::vector code in the reverse mode #1071

Open
gojakuch opened this issue Sep 2, 2024 · 0 comments
Open

Comments

@gojakuch
Copy link
Collaborator

gojakuch commented Sep 2, 2024

reproducer:

#include "clad/Differentiator/Differentiator.h"
#include "clad/Differentiator/STLBuiltins.h"
#include <vector>
#include <iostream>

double fn(double x, double y) {
  std::vector<double> a;
  a.push_back(0); // the problem is with pushing literal values for some reason
  a[1] = x*x;
  return a[1];
}

int main(int argc, char* argv[]) {
    double dx=0, dy=0;
    auto df = clad::gradient(fn, "x, y");
    std::cout << fn(3, 4) << '\n';
    df.execute(3, 4, &dx, &dy);
    std::cout << dx << ' ' << dy << '\n';
}
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