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

Assertion `!subretused' failed when compiling simple example with custom derivatives. #1395

Open
tthsqe12 opened this issue Aug 30, 2023 · 2 comments · May be fixed by #1473
Open

Assertion `!subretused' failed when compiling simple example with custom derivatives. #1395

tthsqe12 opened this issue Aug 30, 2023 · 2 comments · May be fixed by #1473

Comments

@tthsqe12
Copy link
Contributor

tthsqe12 commented Aug 30, 2023

I don't see anything wrong with doing

extern double F(double);
extern double Fp(double);

__attribute__((noinline)) double f(double x) {return F(x);}
void f_aug(double x) { }
double f_rev(double x, double grad_out) {return grad_out*Fp(x);}
void* __enzyme_register_gradient_f[3] = { (void*)f, (void*)f_aug, (void*)f_rev };

void g(double x[5]) {
    x[2] = f(x[0] + x[1]);
}

template<typename ...T> void __enzyme_autodiff(void*, T...);

void g_auto(double x[5], double x_b[5]) {
    __enzyme_autodiff((void*)g, x, x_b);
}

but

assert(!subretused);
fails here. My command line is nothing unusual (-O0 fails the same way)

0.	Program arguments: /home/pc/cpp/llvm-project-llvmorg-15.0.7/build/bin/clang++ -O3 -fno-exceptions tcustom.cpp -S -emit-llvm -o output.ll -fpass-plugin=/home/pc/cpp/git/Enzyme/enzyme/build/Enzyme/ClangEnzyme-15.so -Xclang -load -Xclang /home/pc/cpp/git/Enzyme/enzyme/build/Enzyme/ClangEnzyme-15.so
@wsmoses
Copy link
Member

wsmoses commented Aug 30, 2023

Ah your augmented primal should also return the original result of the function

@tthsqe12
Copy link
Contributor Author

tthsqe12 commented Aug 30, 2023

OK. Why this need not be done in Integration/ReverseMode/invsqrt.c? (This is where I learned about enzyme_register_gradient)

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.

2 participants