-
-
Notifications
You must be signed in to change notification settings - Fork 11.2k
BUG: np.array cleared errors occured in PyMemoryView_FromObject #13507
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
BUG: np.array cleared errors occured in PyMemoryView_FromObject #13507
Conversation
This change isn't enough - there are two calls to |
Done, apologies for the delay. |
b0e2599
to
de06bf6
Compare
It does seem that this logic is sufficiently convoluted to justify a test, but it seems such a test would require a custom Let me know if you want help with that |
While this change makes EagerTensor.numpy __array__ redundant, it does not remove __array__ due to numpy/numpy#13507. Note also that unlike __array__, the buffer interface does not lead to a performance regression when np.array infers the dimensionality of [tensor]. See tensorflow#27692 and numpy/numpy#8562 for details. PiperOrigin-RevId: 249888195
This commit changes PyMemoryView_FromObject call sites to only clear BufferError and TypeError. Any other error will be raised to the caller of np.array.
de06bf6
to
cfb5749
Compare
Thanks @superbobry |
@mattip sorry for not commenting earlier. I implemented a test but discovered more calls to |
@superbobry is there harm in what I merged? It is fine to fix more in a follow-on, as long as the current state has no regressions from the previous one. |
No, no harm, but the commit description might be misleading :) |
This commit changes PyMemoryView_FromObject call sites to only
clear BufferError and TypeError. Any other error will be raised
to the caller of np.array.
I'd be happy to add a test for this, but it requires writing an extension class
with a custom buffer interface implementation. Should I do that?