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 crashes when trying to initialise a class type declaration in the reverse mode #1082

Closed
gojakuch opened this issue Sep 4, 2024 · 1 comment · Fixed by #1212
Closed
Assignees
Milestone

Comments

@gojakuch
Copy link
Collaborator

gojakuch commented Sep 4, 2024

reproducer:

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

double fn(double x, double y) {
    std::vector<double> v{1, 2, 3}; // this doesn't work
    return v[0];
}

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

same thing is happening with other types

@gojakuch
Copy link
Collaborator Author

I guess what needs to be done is that we need some support of the initializer_list in the reverse mode and then we just need to make custom pullbacks for constructors that use it.

PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jan 7, 2025
Previously, we replaced ``std::initializer_list`` variables with ``clad::array`` in the reverse mode so that they become modifiable. This PR moves the logic for type replacement from ``RMV::DifferentiateVarDecl`` to a``RMV::CloneType`` to use it to handle constructors with ``std::initializer_list`` parameters.

Fixes vgvassilev#1082.
PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jan 7, 2025
Previously, we replaced ``std::initializer_list`` variables with ``clad::array`` in the reverse mode so that they become modifiable. This PR moves the logic for type replacement from ``RMV::DifferentiateVarDecl`` to a``RMV::CloneType`` to use it to handle constructors with ``std::initializer_list`` parameters.

Fixes vgvassilev#1082.
@vgvassilev vgvassilev added this to the v1.9 milestone Jan 7, 2025
PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jan 7, 2025
Previously, we replaced ``std::initializer_list`` variables with ``clad::array`` in the reverse mode so that they become modifiable. This PR moves the logic for type replacement from ``RMV::DifferentiateVarDecl`` to a``RMV::CloneType`` to use it to handle constructors with ``std::initializer_list`` parameters.

Fixes vgvassilev#1082.
PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jan 7, 2025
Previously, we replaced ``std::initializer_list`` variables with ``clad::array`` in the reverse mode so that they become modifiable. This PR moves the logic for type replacement from ``RMV::DifferentiateVarDecl`` to a``RMV::CloneType`` to use it to handle constructors with ``std::initializer_list`` parameters.

Fixes vgvassilev#1082.
PetroZarytskyi added a commit to PetroZarytskyi/clad that referenced this issue Jan 10, 2025
Previously, we replaced ``std::initializer_list`` variables with ``clad::array`` in the reverse mode so that they become modifiable. This PR moves the logic for type replacement from ``RMV::DifferentiateVarDecl`` to a``RMV::CloneType`` to use it to handle constructors with ``std::initializer_list`` parameters.

Fixes vgvassilev#1082.
vgvassilev pushed a commit that referenced this issue Jan 11, 2025
* Support std::initializer_list parameters in the reverse mode.

Previously, we replaced ``std::initializer_list`` variables with ``clad::array`` in the reverse mode so that they become modifiable. This PR moves the logic for type replacement from ``RMV::DifferentiateVarDecl`` to a``RMV::CloneType`` to use it to handle constructors with ``std::initializer_list`` parameters.

Fixes #1082.
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

Successfully merging a pull request may close this issue.

3 participants