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

Clad fails to provide enough arguments for the pullback if the function's return value isn't used #1105

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

Comments

@gojakuch
Copy link
Collaborator

reproducer:

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

struct S {
    double r;

    double g(double x) {
        r = x;
        return x;
    }
};

double fn(double x, double y) {
    S s;
    s.r = y;
    s.g(x);
    return s.r; // x
}

int main() {
    double dx=0, dy=0; 
    auto df = clad::gradient(fn);
    df.execute(3, 4, &dx, &dy);
    std::cout << dx << ' ' << dy <<'\n';
}

here, the method S::g returns a double value that's not being used. in this case, Clad fails to provide enough arguments for its pullback call when generating the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants