-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Fix vectors data on GPU #7626
Fix vectors data on GPU #7626
Conversation
I can't seem to add this as a suggestion because it's too far from the existing edits, but after running the GPU tests with all the suggested changes I still run into problems with if vector is not None:
+ xp = get_array_module(self.data)
+ vector = xp.asarray(vector)
self.data[row] = vector |
Hm, maybe? I tried to ensure that that wouldn't be necessary in the edits, but we can add it for robustness anyway. |
Maybe I did something wrong, but there are a number of tests that add numpy arrays as the new vector row, which leads to spaCy/spacy/tests/doc/test_doc_api.py Lines 235 to 240 in 8b3eec6
I don't think we want to require people using |
Oh shoot, I thought I tracked down most of those tests and changed them to use current ops. |
Description
vectors.data
can be of typenumpy.ndarray
orcupy.ndarray
, but recent GPU testing highlighted some trouble when usingcupy
. This PR makes the code more general by relying on current ops, and also avoids using the implicit conversion to scalar bynumpy
(whichcupy
doesn't do).Tested locally, this seemed to fix the trouble from PR #7293 🤞
Types of change
bug fix
Checklist