Skip to content

Commit 5503a22

Browse files
authored
Merge branch 'master' into update_tests
2 parents a077418 + 6061b6e commit 5503a22

File tree

134 files changed

+17584
-2285
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+17584
-2285
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ repos:
3434
(?x)^(
3535
dpnp/tests/test_arraycreation.py|
3636
dpnp/tests/test_sycl_queue.py|
37-
dpnp/tests/test_usm_type.py
37+
dpnp/tests/test_usm_type.py|
38+
dpnp/tests/third_party/cupy/core_tests/test_nep50_examples.py
3839
)$
3940
- id: python-no-log-warn
4041
- id: python-use-type-annotations

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
### Fixed
1414

1515

16+
## [0.16.1] - 12/06/2024
17+
18+
This is a bug-fix release.
19+
20+
### Changed
21+
22+
* Changed to use `Miniforge` installer in GitHub actions [#2057](https://github.com/IntelPython/dpnp/pull/2057)
23+
* Updated `README.md` to reflect current installation requirements and available options [#2166](https://github.com/IntelPython/dpnp/pull/2166)
24+
* Corrected the list of owners and code maintainers [#2185](https://github.com/IntelPython/dpnp/pull/2185)
25+
* Bumped the version of `oneMKL` interface used in dpnp build by default to align it with `2025.0` oneAPI release [#2193](https://github.com/IntelPython/dpnp/pull/2193)
26+
27+
### Fixed
28+
29+
* Resolved an issue with Compute Follows Data inconsistency in `dpnp.extract` function [#2172](https://github.com/IntelPython/dpnp/pull/2172)
30+
* Resolved an import error when using `dpnp` in virtual environment on Linux [#2199](https://github.com/IntelPython/dpnp/pull/2199)
31+
* Fixed incorrect result produced by `dpnp.fft.fft` function when input array has negative strides [#2202](https://github.com/IntelPython/dpnp/pull/2202)
32+
* Fixed an issue with `numpy.ndarray` input processing in the `dpnp.from_dlpack` function and updated the documentation [#2209](https://github.com/IntelPython/dpnp/pull/2209)
33+
* Resolved a compilation error when building with DPC++ 2025.1 compiler [#2211](https://github.com/IntelPython/dpnp/pull/2211)
34+
35+
1636
## [0.16.0] - 10/14/2024
1737

1838
This release reaches an important milestone by making offloading fully asynchronous. Calls to `dpnp` submit tasks for execution to DPC++ runtime and return without waiting for execution of these tasks to finish. The sequential semantics a user comes to expect from execution of Python script is preserved though.

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ def _can_document_member(member, *args, **kwargs):
220220
"python": ("https://docs.python.org/3/", None),
221221
"numpy": ("https://docs.scipy.org/doc/numpy/", None),
222222
"scipy": ("https://docs.scipy.org/doc/scipy/reference/", None),
223+
"dpctl": ("https://intelpython.github.io/dpctl/latest/", None),
223224
}
224225

225226
# If true, `todo` and `todoList` produce output, else they produce nothing.

dpnp/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
[os.getenv("PATH", ""), mypath, dpctlpath]
5050
)
5151

52+
# Borrowed from DPCTL
53+
from dpctl.tensor import DLDeviceType
54+
5255
from dpnp.dpnp_array import dpnp_array as ndarray
5356
from dpnp.dpnp_flatiter import flatiter as flatiter
5457
from dpnp.dpnp_iface_types import *

dpnp/backend/kernels/dpnp_krnl_common.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,23 @@
3535
#include "queue_sycl.hpp"
3636
#include <dpnp_iface.hpp>
3737

38+
/**
39+
* Version of SYCL DPC++ 2025.1 compiler where support of
40+
* sycl::ext::oneapi::experimental::properties was added.
41+
*/
42+
#ifndef __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
43+
#define __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT 20241129
44+
#endif
45+
3846
namespace mkl_blas = oneapi::mkl::blas;
3947
namespace mkl_blas_cm = oneapi::mkl::blas::column_major;
4048
namespace mkl_blas_rm = oneapi::mkl::blas::row_major;
4149
namespace mkl_lapack = oneapi::mkl::lapack;
4250

51+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
52+
namespace syclex = sycl::ext::oneapi::experimental;
53+
#endif
54+
4355
template <typename _KernelNameSpecialization1,
4456
typename _KernelNameSpecialization2,
4557
typename _KernelNameSpecialization3>
@@ -78,8 +90,13 @@ sycl::event dot(sycl::queue &queue,
7890
cgh.parallel_for(
7991
sycl::range<1>{size},
8092
sycl::reduction(
81-
result_out, std::plus<_DataType_output>(),
82-
sycl::property::reduction::initialize_to_identity{}),
93+
result_out, sycl::plus<_DataType_output>(),
94+
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
95+
syclex::properties(syclex::initialize_to_identity)
96+
#else
97+
sycl::property::reduction::initialize_to_identity {}
98+
#endif
99+
),
83100
[=](sycl::id<1> idx, auto &sum) {
84101
sum += static_cast<_DataType_output>(
85102
input1_in[idx * input1_strides]) *

dpnp/dpnp_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def mT(self):
150150
if self.ndim < 2:
151151
raise ValueError("matrix transpose with ndim < 2 is undefined")
152152

153-
return self._array_obj.mT
153+
return dpnp_array._create_from_usm_ndarray(self._array_obj.mT)
154154

155155
def to_device(self, target_device):
156156
"""Transfer array to target device."""

dpnp/dpnp_iface.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
"check_limitations",
6363
"check_supported_arrays_type",
6464
"default_float_type",
65-
"from_dlpack",
6665
"get_dpnp_descriptor",
6766
"get_include",
6867
"get_normalized_queue_device",
@@ -443,60 +442,6 @@ def default_float_type(device=None, sycl_queue=None):
443442
return map_dtype_to_device(float64, _sycl_queue.sycl_device)
444443

445444

446-
def from_dlpack(obj, /, *, device=None, copy=None):
447-
"""
448-
Create a dpnp array from a Python object implementing the ``__dlpack__``
449-
protocol.
450-
451-
See https://dmlc.github.io/dlpack/latest/ for more details.
452-
453-
Parameters
454-
----------
455-
obj : object
456-
A Python object representing an array that implements the ``__dlpack__``
457-
and ``__dlpack_device__`` methods.
458-
device : {:class:`dpctl.SyclDevice`, :class:`dpctl.SyclQueue`,
459-
:class:`dpctl.tensor.Device`, tuple, None}, optional
460-
Array API concept of a device where the output array is to be placed.
461-
``device`` can be ``None``, an oneAPI filter selector string,
462-
an instance of :class:`dpctl.SyclDevice` corresponding to
463-
a non-partitioned SYCL device, an instance of :class:`dpctl.SyclQueue`,
464-
a :class:`dpctl.tensor.Device` object returned by
465-
:attr:`dpctl.tensor.usm_ndarray.device`, or a 2-tuple matching
466-
the format of the output of the ``__dlpack_device__`` method,
467-
an integer enumerator representing the device type followed by
468-
an integer representing the index of the device.
469-
Default: ``None``.
470-
copy {bool, None}, optional
471-
Boolean indicating whether or not to copy the input.
472-
473-
* If `copy``is ``True``, the input will always be copied.
474-
* If ``False``, a ``BufferError`` will be raised if a copy is deemed
475-
necessary.
476-
* If ``None``, a copy will be made only if deemed necessary, otherwise,
477-
the existing memory buffer will be reused.
478-
479-
Default: ``None``.
480-
481-
Returns
482-
-------
483-
out : dpnp_array
484-
Returns a new dpnp array containing the data from another array
485-
(obj) with the ``__dlpack__`` method on the same device as object.
486-
487-
Raises
488-
------
489-
TypeError:
490-
if `obj` does not implement ``__dlpack__`` method
491-
ValueError:
492-
if the input array resides on an unsupported device
493-
494-
"""
495-
496-
usm_res = dpt.from_dlpack(obj, device=device, copy=copy)
497-
return dpnp_array._create_from_usm_ndarray(usm_res)
498-
499-
500445
def get_dpnp_descriptor(
501446
ext_obj,
502447
copy_when_strides=True,

dpnp/dpnp_iface_arraycreation.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"fromfunction",
7676
"fromiter",
7777
"fromstring",
78+
"from_dlpack",
7879
"full",
7980
"full_like",
8081
"geomspace",
@@ -2047,6 +2048,93 @@ def fromstring(
20472048
)
20482049

20492050

2051+
def from_dlpack(x, /, *, device=None, copy=None):
2052+
"""
2053+
Constructs :class:`dpnp.ndarray` or :class:`numpy.ndarray` instance from
2054+
a Python object `x` that implements ``__dlpack__`` protocol.
2055+
2056+
For full documentation refer to :obj:`numpy.from_dlpack`.
2057+
2058+
Parameters
2059+
----------
2060+
x : object
2061+
A Python object representing an array that implements the ``__dlpack__``
2062+
and ``__dlpack_device__`` methods.
2063+
device : {None, string, tuple, device}, optional
2064+
Device where the output array is to be placed. `device` keyword values
2065+
can be:
2066+
2067+
* ``None`` : The data remains on the same device.
2068+
* oneAPI filter selector string : SYCL device selected by filter
2069+
selector string.
2070+
* :class:`dpctl.SyclDevice` : Explicit SYCL device that must correspond
2071+
to a non-partitioned SYCL device.
2072+
* :class:`dpctl.SyclQueue` : Implies SYCL device targeted by the SYCL
2073+
queue.
2074+
* :class:`dpctl.tensor.Device` : Implies SYCL device
2075+
``device.sycl_queue``. The `device` object is obtained via
2076+
:attr:`dpctl.tensor.usm_ndarray.device`.
2077+
* ``(device_type, device_id)`` : 2-tuple matching the format of the
2078+
output of the ``__dlpack_device__`` method: an integer enumerator
2079+
representing the device type followed by an integer representing
2080+
the index of the device. The only supported :class:`dpnp.DLDeviceType`
2081+
device types are ``"kDLCPU"`` and ``"kDLOneAPI"``.
2082+
2083+
Default: ``None``.
2084+
copy : {bool, None}, optional
2085+
Boolean indicating whether or not to copy the input.
2086+
2087+
* If `copy` is ``True``, the input will always be copied.
2088+
* If ``False``, a ``BufferError`` will be raised if a copy is deemed
2089+
necessary.
2090+
* If ``None``, a copy will be made only if deemed necessary, otherwise,
2091+
the existing memory buffer will be reused.
2092+
2093+
Default: ``None``.
2094+
2095+
Returns
2096+
-------
2097+
out : {dpnp.ndarray, numpy.ndarray}
2098+
An array containing the data in `x`. When `copy` is ``None`` or
2099+
``False``, this may be a view into the original memory.
2100+
The type of the returned object depends on where the data backing up
2101+
input object `x` resides. If it resides in a USM allocation on a SYCL
2102+
device, the type :class:`dpnp.ndarray` is returned, otherwise if it
2103+
resides on ``"kDLCPU"`` device the type is :class:`numpy.ndarray`, and
2104+
otherwise an exception is raised.
2105+
2106+
Raises
2107+
------
2108+
TypeError
2109+
if `obj` does not implement ``__dlpack__`` method
2110+
ValueError
2111+
if data of the input object resides on an unsupported device
2112+
2113+
Notes
2114+
-----
2115+
If the return type is :class:`dpnp.ndarray`, the associated SYCL queue is
2116+
derived from the `device` keyword. When `device` keyword value has type
2117+
:class:`dpctl.SyclQueue`, the explicit queue instance is used, when `device`
2118+
keyword value has type :class:`dpctl.tensor.Device`, the
2119+
``device.sycl_queue`` is used. In all other cases, the cached SYCL queue
2120+
corresponding to the implied SYCL device is used.
2121+
2122+
Examples
2123+
--------
2124+
>>> import dpnp as np
2125+
>>> import numpy
2126+
>>> x = numpy.arange(10)
2127+
>>> # create a view of the numpy array "x" in dpnp:
2128+
>>> y = np.from_dlpack(x)
2129+
2130+
"""
2131+
2132+
result = dpt.from_dlpack(x, device=device, copy=copy)
2133+
if isinstance(result, dpt.usm_ndarray):
2134+
return dpnp_array._create_from_usm_ndarray(result)
2135+
return result
2136+
2137+
20502138
def full(
20512139
shape,
20522140
fill_value,

dpnp/dpnp_iface_indexing.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"fill_diagonal",
7070
"flatnonzero",
7171
"indices",
72+
"iterable",
7273
"ix_",
7374
"mask_indices",
7475
"ndindex",
@@ -1033,6 +1034,47 @@ def indices(
10331034
return res
10341035

10351036

1037+
def iterable(y):
1038+
"""
1039+
Check whether or not an object can be iterated over.
1040+
1041+
For full documentation refer to :obj:`numpy.iterable`.
1042+
1043+
Parameters
1044+
----------
1045+
y : object
1046+
Input object.
1047+
1048+
Returns
1049+
-------
1050+
out : bool
1051+
Return ``True`` if the object has an iterator method or is a sequence
1052+
and ``False`` otherwise.
1053+
1054+
Examples
1055+
--------
1056+
>>> import dpnp as np
1057+
>>> np.iterable([1, 2, 3])
1058+
True
1059+
>>> np.iterable(2)
1060+
False
1061+
1062+
In most cases, the results of ``np.iterable(obj)`` are consistent with
1063+
``isinstance(obj, collections.abc.Iterable)``. One notable exception is
1064+
the treatment of 0-dimensional arrays:
1065+
1066+
>>> from collections.abc import Iterable
1067+
>>> a = np.array(1.0) # 0-dimensional array
1068+
>>> isinstance(a, Iterable)
1069+
True
1070+
>>> np.iterable(a)
1071+
False
1072+
1073+
"""
1074+
1075+
return numpy.iterable(y)
1076+
1077+
10361078
def ix_(*args):
10371079
"""Construct an open mesh from multiple sequences.
10381080

0 commit comments

Comments
 (0)