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

Enzyme: Cannot cast __enzyme_autodiff primal argument 16 #1772

Open
efeklisov opened this issue Feb 29, 2024 · 7 comments
Open

Enzyme: Cannot cast __enzyme_autodiff primal argument 16 #1772

efeklisov opened this issue Feb 29, 2024 · 7 comments

Comments

@efeklisov
Copy link

I'm getting a weird typecasting issue in Enzyme. What could be the source of it?

https://fwd.gymni.ch/vATLS0

@wsmoses
Copy link
Member

wsmoses commented Feb 29, 2024 via email

@efeklisov
Copy link
Author

I hope I understood you correctly, but I see a similar issue

https://fwd.gymni.ch/TFoPoL

@wsmoses
Copy link
Member

wsmoses commented Feb 29, 2024

C var-args passes things by value, so you need to & the args to make them pointers in that case: https://fwd.gymni.ch/zWsQwn

@wsmoses
Copy link
Member

wsmoses commented Feb 29, 2024

Hopefully that solve your issue, however keeping this open for now so we can make the nice c++ syntax happy with it [and obviate the need for the extra work]: https://fwd.gymni.ch/UDe5lg

@samuelpmishLLNL @samuelpmish

@ipcamit
Copy link

ipcamit commented May 28, 2024

Sorry, I am having same issue, in a small example I was creating to ask unrelated question. Why is the minimal function below gives same error?

https://fwd.gymni.ch/NzHCYv

int __enzyme_const, __enzyme_dup;

void __enzyme_autodiffs(void (*) (double, double, double*), ...);

void math(double a, double b , double *result) {}

void grad(double a, double b, double *result, double *d_result) {

    double d_a = 0.0;
    double d_b = 0.0;
    __enzyme_autodiffs(math,
        __enzyme_dup, a, d_a,
        __enzyme_dup, b, d_b,
        __enzyme_dup, result, d_result);

}

@samuelpmish
Copy link
Collaborator

@ipcamit I think you're just using the wrong names for some of the enzyme stuff.

try:

  • __enzyme_autodiff rather than __enzyme_autodiffs
  • enzyme_const instead of __enzyme_const
  • enzyme_dup instead of __enzyme_dup

see: https://fwd.gymni.ch/k3qaoa

@ipcamit
Copy link

ipcamit commented May 29, 2024

This is embarrassing! I was using __enzyme_autodiff properly, and was trying to see if its name change will affect the compilation. But completely forgot about enzyme_dup, I was really sure that all things enzyme start like __enzyme...! Thank you for taking time to look into this.

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

4 participants