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

max function derivative #101

Closed
prangel-git opened this issue Dec 27, 2020 · 3 comments
Closed

max function derivative #101

prangel-git opened this issue Dec 27, 2020 · 3 comments
Assignees

Comments

@prangel-git
Copy link

I've been playing around with Enzyme. Enzyme seems to be able to find the derivative of the following function just fine

double fun(double x) {
if(x>=0) return x;
return x * 0;
}

However, when I do "return 0" instead of "return x * 0", it calculates the derivative always equal to zero. I assumed that somehow the constant confuses the library, but the following functions finds the correct derivative:

double fun(double x) {
if(x<=1) return x;
return 1;
}

so, I guess it might be something to do with zero? I am not sure.

@wsmoses wsmoses self-assigned this Dec 27, 2020
@wsmoses
Copy link
Member

wsmoses commented Dec 27, 2020

Mysterious, this definitely is a bug (and I've confirmed it locally). My guess is that activity analysis is being a bit too aggressive. I'll get back with a fix shortly.

@wsmoses
Copy link
Member

wsmoses commented Dec 27, 2020

It was indeed a slightly too aggressive activity analysis with a three line fix (2223fc1).

Since there's pending CI changes in #100 I'm combining this into that PR (which will go in once reviewed).

@prangel-git
Copy link
Author

Nice, thanks for the quick turn around.

Best!

@wsmoses wsmoses closed this as completed Jan 4, 2021
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

2 participants