-
-
Notifications
You must be signed in to change notification settings - Fork 26k
[MRG-1] ENH: Allow float32 to pass through with copy #5932
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
Conversation
In general the good looks good, but I would like to know the exact problem that you are trying to solve. Ideally, this problem should be illustrated by a test that fails without your patch and passes with it. The idea being that it will guide later refactoring. In the long run, we want to tackle the issue of multiple types in Cython using fused types. |
I found that computing cosine distance fails on 32-bit floating point sparse arrays. Added regression tests. I added some clarifying documentation on the Fused types would be nice. |
bbd2675
to
fe6b225
Compare
This fix should work, but I'm afraid that this is equivalent to changing the dtype of the sparse matrix prior and passing it to the function as it produces a copy. It would be great if you could add fused type support so that we can do this without copying ! Just for this function would be a great start. |
I had a quick look at this today - the code looks fine to me, and the fix works. I would recommend merging it anyway - but fused types needs done too. |
np.ndarray[DOUBLE, ndim=1] data = X.data | ||
# might copy | ||
np.ndarray[DOUBLE, ndim=1] data = np.asarray(X.data, | ||
dtype=np.float64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change to assign_rows_csr
is not tested by the new regression test.
The only correct fix for those 2 functions is to use cython fused types for Therefore I am -1 on this part of the PR. +0 for the change to |
Agreed with the analysis. Sorry for my previous 👍, it would have been
That would be good. |
Can we close this as the incorrect patch, while waiting for a fix as part of @yenchenlin1994's GSoC? |
That's what I'm doing anyway... |
This is the easy path to fixing this.
I was a bit surprised to see the float64 default and the copies elsewhere in the sparse functions. Are there rules for consistency as to float32 vs. float64 in the Cython code?