Skip to content

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