-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add methods __bool__, __float__ and __int__ to usm_ndarray #578
Conversation
@densmirn can you also implement |
import dpctl.tensor as dpt
X = dpt.usm_ndarray(10, 'd')
float(X[:1]) # raises TypeError This works with NumPy: import numpy as np
X = np.ndarray(10, 'd')
float(X[:1]) # produces a float It breaks with the current code because X = dpt.usm_ndarray(10, 'd')
X[:1].usm_data.copy_to_host().view('d').shape # outputs (10,) Thus instead of Ideally, in a future, we should avoid copying the entire underlying buffer. |
Actually slice of array can be different, e.g.: import numpy as np
X = np.arange(10)
float(X[:1]) # 0.0
float(X[2:3]) # 2.0 So when we copy data to host we don't know the slice: Looks like it should be somehow handled on |
@oleksandr-pavlyk could you please look at last comment? |
This is affected by #583 |
np.number comprises np.integer and np.inexact, so replace issubdtype(dt.type, np.inexact) or issubdtype(dt.type, np.number) with more efficient issubdtype(dt.type, np.number). Also allowed dtype.type to be np.bool_, to accommodate dtype="|b1" Replaced single quotation marks with double quotation marks per linter's flavor.
1f50ed8
to
e32b395
Compare
This PR(tests) have uncovered another problem which I fixed. It was inability of memory objects to understand objects with Also added tests to cover new functionality. |
I also added |
Closes #545