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

Fixed error in grad_chooser (for e.g., max) when dtype is not numpy float64 #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kswersky
Copy link

Grads of e.g., sum(anp.max(x, 1)) fail when x is of dtype float32. The issue is that numpy implicitly casts to float64 when dividing a float32 array by an int64 array, which happens in grad_chooser. This fixes the issue by casting appropriately in grad_chooser.

@alexbw
Copy link
Contributor

alexbw commented Mar 20, 2017

FYI, I have taken some autograd gradients for a side project, and found float64 casting performance bugs scattered around.

@j-towns
Copy link
Collaborator

j-towns commented Mar 20, 2017

@alexbw is this when you're using float32 arrays?

It should be straightforward to add float32 tests. I think adding something to check_fun_and_grads/check_grads should cover almost everything.

@alexbw
Copy link
Contributor

alexbw commented Mar 20, 2017 via email

@j-towns
Copy link
Collaborator

j-towns commented Mar 20, 2017

Yeah it's even better than 2x for some things. I made this pr a little while ago but I'll make another one to add testing for float32 dtype support accross all the primitives.

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 this pull request may close these issues.

3 participants