Skip to content

Commit 11e28de

Browse files
Merge master into update_svd_cuda
2 parents 7a8c11c + 3f737be commit 11e28de

File tree

4 files changed

+70
-3
lines changed

4 files changed

+70
-3
lines changed

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_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

dpnp/tests/test_indexing.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,14 @@ def test_ix_error(self, xp, shape):
337337
assert_raises(ValueError, xp.ix_, xp.ones(shape))
338338

339339

340+
class TestIterable:
341+
@pytest.mark.parametrize("data", [[1.0], [2, 3]])
342+
def test_basic(self, data):
343+
a = numpy.array(data)
344+
ia = dpnp.array(a)
345+
assert dpnp.iterable(ia) == numpy.iterable(a)
346+
347+
340348
@pytest.mark.parametrize(
341349
"shape", [[1, 2, 3], [(1, 2, 3)], [(3,)], [3], [], [()], [0]]
342350
)

dpnp/tests/third_party/cupy/creation_tests/test_ranges.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def test_linspace_float_overflow(self, xp):
172172
dtype = cupy.default_float_type()
173173
return xp.linspace(0.0, xp.finfo(dtype).max / 5, 10, dtype=dtype)
174174

175-
@testing.numpy_cupy_allclose()
175+
@testing.numpy_cupy_allclose(rtol={numpy.float32: 1e-6, "default": 1e-7})
176176
def test_linspace_float_underflow(self, xp):
177177
# find minimum subnormal number
178178
dtype = cupy.default_float_type()

0 commit comments

Comments
 (0)