-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implementation of histogram with sycl kernel #2027
base: master
Are you sure you want to change the base?
Implementation of histogram with sycl kernel #2027
Conversation
f1c7227
to
6590a45
Compare
1321444
to
bc18622
Compare
bc18622
to
088beb5
Compare
dpnp/dpnp_iface_histograms.py
Outdated
"supported types" | ||
) | ||
|
||
a_casted = a.astype(a_bin_dtype, order="C", copy=False) |
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.
Because a
may be usm_ndarray
(according to docstring), it is not safe to use a.astype
, since usm_ndarray
does not implement such a method. Instead dpctl.tensor.astype
should be used, or support for such input types should not be advertised.
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.
Done, replaced with dpnp.astype(a, ...)
Quick validation via independent implementation: def histogram1d_impl_tensor(data : dpt.usm_ndarray, bins : dpt.usm_ndarray) -> dpt.usm_ndarray:
assert data.ndim == 1
assert bins.ndim == 1
assert bins.shape[0] > 1
bin_idx = dpt.searchsorted(bins, data)
_, c = dpt.unique_counts(dpt.sort(bin_idx))
return c
|
#include <vector> | ||
|
||
// dpctl tensor headers | ||
#include "utils/type_dispatch.hpp" |
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.
#include "utils/type_dispatch.hpp" | |
#include "dpctl4pybind11.hpp" | |
#include "utils/type_dispatch.hpp" |
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.
Done
7725c2c
to
e6c66d1
Compare
e6c66d1
to
020ea2c
Compare
Implemention of histogram with sycl_kernel.
This PR adds generic histogram kernel which can be used in the future to implement other versions of histogram such as
bincount
,histogram2d
andhistogramdd
or specialize kernel for special cases like uniform bins.sycl kernel covers only specific datatype and usm memory types. Unsupported cases are covered by additional copy.