-
Notifications
You must be signed in to change notification settings - Fork 32
Allow Python scalars as the search values in dpt.searchsorted
#2225
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
base: master
Are you sure you want to change the base?
Conversation
|
View rendered docs @ https://intelpython.github.io/dpctl/pulls/2225/index.html |
|
Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_104 ran successfully. |
b7de201 to
e85940e
Compare
|
Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_104 ran successfully. |
|
Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_105 ran successfully. |
|
Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_106 ran successfully. |
bda9809 to
b7c56e1
Compare
|
Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_106 ran successfully. |
|
|
||
| if not isinstance(x2, usm_ndarray): | ||
| x2 = dpt.asarray(x2, dtype=dt2, usm_type=res_usm_type, sycl_queue=q) | ||
| if x2.dtype != dt: |
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.
| if x2.dtype != dt: | |
| elif x2.dtype != dt: |
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 is not meant to be an elif. x2 is taken to dt2 first if not usm_ndarray then is cast to dt which is the resolved dtype. This way, it passes through dt2 under all circumstances.
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.
Then it's unclear for me, why do we need to run 2 kernels in that case?
- to convert a scalar to a temporary usm_ndarray and to copy back to the result
- to cast the array to
dt
What is a drawback to pass dt directly to asarray call?
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.
Also, in the sequence:
- cast
x1todt - cast
x2to usm_ndarray if any - cast
x2todt
We have to make step 2 as the 1st or as the last in the sequence, but not in the middle, because currently step 2 depends on events from step 1, but shouldn't.
And from other side, step 2 produces depending events which we must pass to step 3, but we didn't (asarray must be completed before we can start casting x2 to dt).
|
Array API standard conformance tests for dpctl=0.22.0dev0=py310h93fe807_110 ran successfully. |
| "shape as the first argument array" | ||
| ) | ||
| res = empty(x1.shape, dtype=x1_dt, usm_type=x1.usm_type, sycl_queue=q) | ||
| res = empty(x1.shape, dtype=x1_dt, usm_type=x1_usm_type, sycl_queue=q) |
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.
Isn't that exactly the same as below?
| res = empty(x1.shape, dtype=x1_dt, usm_type=x1_usm_type, sycl_queue=q) | |
| res = empty_like(x1) |
|
|
||
| if not isinstance(x2, usm_ndarray): | ||
| x2 = dpt.asarray(x2, dtype=dt2, usm_type=res_usm_type, sycl_queue=q) | ||
| if x2.dtype != dt: |
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.
Then it's unclear for me, why do we need to run 2 kernels in that case?
- to convert a scalar to a temporary usm_ndarray and to copy back to the result
- to cast the array to
dt
What is a drawback to pass dt directly to asarray call?
|
|
||
| if not isinstance(x2, usm_ndarray): | ||
| x2 = dpt.asarray(x2, dtype=dt2, usm_type=res_usm_type, sycl_queue=q) | ||
| if x2.dtype != dt: |
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.
Also, in the sequence:
- cast
x1todt - cast
x2to usm_ndarray if any - cast
x2todt
We have to make step 2 as the 1st or as the last in the sequence, but not in the middle, because currently step 2 depends on events from step 1, but shouldn't.
And from other side, step 2 produces depending events which we must pass to step 3, but we didn't (asarray must be completed before we can start casting x2 to dt).
This PR proposes permitting the search values of
dpt.searchsortedto be Python scalars, a change coming to the 2026 array API specResolves #2224