Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
9c64980
Remove limitations from dpnp.take implementation
antonwolfy Jul 5, 2024
3c7cebc
Add more test to cover specail cases and increase code coverage
antonwolfy Jul 5, 2024
a89136e
Applied pre-commit hook
antonwolfy Jul 5, 2024
f054818
Corrected test_over_index
antonwolfy Jul 5, 2024
aa3d9ba
Merge branch 'master' into impl-take
antonwolfy Jul 7, 2024
7e87cef
Update docsctrings with resolving typos
antonwolfy Jul 7, 2024
cbb7188
Use dpnp.reshape() to change shape and create dpnp array from usm_nda…
antonwolfy Jul 9, 2024
c170c19
Remove limitations from dpnp.place implementation
antonwolfy Jul 7, 2024
2d87bfc
Update relating tests
antonwolfy Jul 7, 2024
b527f77
Roll back changed in dpnp.vander
antonwolfy Jul 7, 2024
dc5e776
Remove data sync at the end of function
antonwolfy Jul 9, 2024
5bac010
Update indexing functions
antonwolfy Jul 7, 2024
f53ab2d
Add missing test scenario
antonwolfy Jul 7, 2024
157de7f
Updated docstring in put_along_axis() and take_along_axis() and rolle…
antonwolfy Jul 9, 2024
d0915b1
Remove data synchronization for dpnp.put()
antonwolfy Jul 9, 2024
e300914
Remove data synchronization for dpnp.nonzero()
antonwolfy Jul 9, 2024
36f2972
Remove data synchronization for dpnp.indices()
antonwolfy Jul 9, 2024
fef9f51
Remove data synchronization for dpnp.extract()
antonwolfy Jul 9, 2024
33b1707
Merge branch 'master' into adopt-indexing-if-to-asynchronous-dpctl-ex…
antonwolfy Jul 10, 2024
23fb47f
Remove data sync in dpnp.get_result_array()
antonwolfy Jul 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ def swapaxes(self, axis1, axis2):

return dpnp.swapaxes(self, axis1=axis1, axis2=axis2)

def take(self, indices, /, *, axis=None, out=None, mode="wrap"):
def take(self, indices, axis=None, out=None, mode="wrap"):
"""
Take elements from an array along an axis.

Expand Down
52 changes: 52 additions & 0 deletions dpnp/dpnp_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"array_equal",
"asnumpy",
"astype",
"as_usm_ndarray",
"check_limitations",
"check_supported_arrays_type",
"convert_single_elem_array_to_scalar",
Expand Down Expand Up @@ -247,6 +248,55 @@ def astype(x1, dtype, order="K", casting="unsafe", copy=True, device=None):
return dpnp_array._create_from_usm_ndarray(array_obj)


def as_usm_ndarray(a, dtype=None, device=None, usm_type=None, sycl_queue=None):
"""
Return :class:`dpctl.tensor.usm_ndarray` from input object `a`.

Parameters
----------
a : {array_like, scalar}
Input array or scalar.
dtype : {None, dtype}, optional
The desired dtype for the result array if new array is creating. If not
given, a default dtype will be used that can represent the values (by
considering Promotion Type Rule and device capabilities when necessary).
Default: ``None``.
device : {None, string, SyclDevice, SyclQueue}, optional
An array API concept of device where the result array is created if
required.
The `device` can be ``None`` (the default), an OneAPI filter selector
string, an instance of :class:`dpctl.SyclDevice` corresponding to
a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,
or a `Device` object returned by
:obj:`dpnp.dpnp_array.dpnp_array.device` property.
Default: ``None``.
usm_type : {None, "device", "shared", "host"}, optional
The type of SYCL USM allocation for the result array if new array
is created.
Default: ``None``.
sycl_queue : {None, SyclQueue}, optional
A SYCL queue to use for result array allocation if required.
Default: ``None``.

Returns
-------
out : usm_ndarray
A dpctl USM ndarray from input array or scalar `a`.
If `a` is instance of :class:`dpnp.ndarray`
or :class:`dpctl.tensor.usm_ndarray`, no array allocation will be done
and `dtype`, `device`, `usm_type`, `sycl_queue` keywords
will be ignored.

"""

if is_supported_array_type(a):
return get_usm_ndarray(a)

return dpt.asarray(
a, dtype=dtype, device=device, usm_type=usm_type, sycl_queue=sycl_queue
)


def check_limitations(
order=None, subok=False, like=None, initial=None, where=True
):
Expand Down Expand Up @@ -579,9 +629,11 @@ def get_result_array(a, out=None, casting="safe"):
"""

if out is None:
synchronize_array_data(a)
return a

if a is out:
synchronize_array_data(a)
return out

dpnp.check_supported_arrays_type(out)
Expand Down
8 changes: 3 additions & 5 deletions dpnp/dpnp_iface_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,9 @@ def _get_bin_edges(a, bins, range, usm_type):
"a and bins must be allocated on the same SYCL queue"
)

bin_edges = dpnp.get_usm_ndarray(bins)
else:
bin_edges = dpt.asarray(
bins, sycl_queue=sycl_queue, usm_type=usm_type
)
bin_edges = dpnp.as_usm_ndarray(
bins, usm_type=usm_type, sycl_queue=sycl_queue
)

if dpnp.any(bin_edges[:-1] > bin_edges[1:]):
raise ValueError(
Expand Down
Loading