Skip to content

Commit 8482f85

Browse files
authored
Merge 2bea896 into a098910
2 parents a098910 + 2bea896 commit 8482f85

25 files changed

+536
-413
lines changed

.github/workflows/conda-package.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107

108108
strategy:
109109
matrix:
110-
python: ['3.9', '3.10', '3.11', '3.12']
110+
python: ['3.9', '3.10', '3.11']
111111

112112
continue-on-error: true
113113

@@ -148,7 +148,7 @@ jobs:
148148
149149
- name: Test conda channel
150150
run: |
151-
mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
151+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
152152
cat ${{ env.ver-json-path }}
153153
154154
- name: Get package version
@@ -182,7 +182,7 @@ jobs:
182182
id: run_tests_linux
183183
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
184184
with:
185-
timeout_minutes: 10
185+
timeout_minutes: 12
186186
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
187187
retry_on: any
188188
command: |
@@ -193,7 +193,7 @@ jobs:
193193
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
194194
195195
test_linux_all_dtypes:
196-
name: Test ['ubuntu-latest', python='${{ matrix.python }}']
196+
name: Test ['ubuntu-latest-all-dtypes', python='${{ matrix.python }}']
197197

198198
needs: build
199199

@@ -274,7 +274,7 @@ jobs:
274274
env:
275275
DPNP_TEST_ALL_INT_TYPES: 1
276276
run: |
277-
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
277+
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
278278
279279
test_windows:
280280
name: Test ['windows-2019', python='${{ matrix.python }}']
@@ -289,7 +289,7 @@ jobs:
289289

290290
strategy:
291291
matrix:
292-
python: ['3.9', '3.10', '3.11', '3.12']
292+
python: ['3.9', '3.10', '3.11']
293293

294294
continue-on-error: true
295295

@@ -348,7 +348,7 @@ jobs:
348348
- name: Test conda channel
349349
run: |
350350
@echo on
351-
mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
351+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
352352
353353
- name: Dump version.json
354354
run: more ${{ env.ver-json-path }}
@@ -409,7 +409,7 @@ jobs:
409409
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
410410
411411
test_windows_all_dtypes:
412-
name: Test ['windows-2019', python='${{ matrix.python }}']
412+
name: Test ['windows-2019-all-dtypes', python='${{ matrix.python }}']
413413

414414
needs: build
415415

dpnp/backend/kernels/dpnp_krnl_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* sycl::ext::oneapi::experimental::properties was added.
4141
*/
4242
#ifndef __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT
43-
#define __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT 20241129
43+
#define __SYCL_COMPILER_REDUCTION_PROPERTIES_SUPPORT 20241208L
4444
#endif
4545

4646
namespace mkl_blas = oneapi::mkl::blas;

dpnp/backend/kernels/elementwise_functions/i0.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* sycl::ext::intel::math::cyl_bessel_i0(x) is fully resolved.
3333
*/
3434
#ifndef __SYCL_COMPILER_BESSEL_I0_SUPPORT
35-
#define __SYCL_COMPILER_BESSEL_I0_SUPPORT 20241114L
35+
#define __SYCL_COMPILER_BESSEL_I0_SUPPORT 20241208L
3636
#endif
3737

3838
#if __SYCL_COMPILER_VERSION >= __SYCL_COMPILER_BESSEL_I0_SUPPORT

dpnp/dpnp_iface_linearalgebra.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@
3737
3838
"""
3939

40+
# pylint: disable=no-name-in-module
4041
import numpy
4142

4243
import dpnp
4344

45+
from .dpnp_utils import map_dtype_to_device
4446
from .dpnp_utils.dpnp_utils_einsum import dpnp_einsum
4547
from .dpnp_utils.dpnp_utils_linearalgebra import (
4648
dpnp_dot,
@@ -64,6 +66,20 @@
6466
]
6567

6668

69+
# TODO: implement a specific scalar-array kernel
70+
def _call_multiply(a, b, out=None):
71+
"""Call multiply function for special cases of scalar-array dots."""
72+
73+
sc, arr = (a, b) if dpnp.isscalar(a) else (b, a)
74+
sc_dtype = map_dtype_to_device(type(sc), arr.sycl_device)
75+
res_dtype = dpnp.result_type(sc_dtype, arr)
76+
if out is not None and out.dtype == arr.dtype:
77+
res = dpnp.multiply(a, b, out=out)
78+
else:
79+
res = dpnp.multiply(a, b, dtype=res_dtype)
80+
return dpnp.get_result_array(res, out, casting="no")
81+
82+
6783
def dot(a, b, out=None):
6884
"""
6985
Dot product of `a` and `b`.
@@ -137,8 +153,7 @@ def dot(a, b, out=None):
137153
raise ValueError("Only C-contiguous array is acceptable.")
138154

139155
if dpnp.isscalar(a) or dpnp.isscalar(b):
140-
# TODO: use specific scalar-vector kernel
141-
return dpnp.multiply(a, b, out=out)
156+
return _call_multiply(a, b, out=out)
142157

143158
a_ndim = a.ndim
144159
b_ndim = b.ndim
@@ -627,8 +642,7 @@ def inner(a, b):
627642
dpnp.check_supported_arrays_type(a, b, scalar_type=True)
628643

629644
if dpnp.isscalar(a) or dpnp.isscalar(b):
630-
# TODO: use specific scalar-vector kernel
631-
return dpnp.multiply(a, b)
645+
return _call_multiply(a, b)
632646

633647
if a.ndim == 0 or b.ndim == 0:
634648
# TODO: use specific scalar-vector kernel
@@ -706,8 +720,7 @@ def kron(a, b):
706720
dpnp.check_supported_arrays_type(a, b, scalar_type=True)
707721

708722
if dpnp.isscalar(a) or dpnp.isscalar(b):
709-
# TODO: use specific scalar-vector kernel
710-
return dpnp.multiply(a, b)
723+
return _call_multiply(a, b)
711724

712725
a_ndim = a.ndim
713726
b_ndim = b.ndim
@@ -1043,8 +1056,7 @@ def tensordot(a, b, axes=2):
10431056
raise ValueError(
10441057
"One of the inputs is scalar, axes should be zero."
10451058
)
1046-
# TODO: use specific scalar-vector kernel
1047-
return dpnp.multiply(a, b)
1059+
return _call_multiply(a, b)
10481060

10491061
return dpnp_tensordot(a, b, axes=axes)
10501062

@@ -1107,13 +1119,13 @@ def vdot(a, b):
11071119
if b.size != 1:
11081120
raise ValueError("The second array should be of size one.")
11091121
a_conj = numpy.conj(a)
1110-
return dpnp.multiply(a_conj, b)
1122+
return _call_multiply(a_conj, b)
11111123

11121124
if dpnp.isscalar(b):
11131125
if a.size != 1:
11141126
raise ValueError("The first array should be of size one.")
11151127
a_conj = dpnp.conj(a)
1116-
return dpnp.multiply(a_conj, b)
1128+
return _call_multiply(a_conj, b)
11171129

11181130
if a.ndim == 1 and b.ndim == 1:
11191131
return dpnp_dot(a, b, out=None, conjugate=True)

dpnp/dpnp_iface_nanfunctions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ def nanstd(
987987
ddof : {int, float}, optional
988988
Means Delta Degrees of Freedom. The divisor used in calculations
989989
is ``N - ddof``, where ``N`` the number of non-NaN elements.
990-
Default: `0.0`.
990+
Default: ``0.0``.
991991
keepdims : {None, bool}, optional
992992
If ``True``, the reduced axes (dimensions) are included in the result
993993
as singleton dimensions, so that the returned array remains
@@ -1087,7 +1087,7 @@ def nanvar(
10871087
ddof : {int, float}, optional
10881088
Means Delta Degrees of Freedom. The divisor used in calculations
10891089
is ``N - ddof``, where ``N`` represents the number of non-NaN elements.
1090-
Default: `0.0`.
1090+
Default: ``0.0``.
10911091
keepdims : {None, bool}, optional
10921092
If ``True``, the reduced axes (dimensions) are included in the result
10931093
as singleton dimensions, so that the returned array remains

dpnp/fft/dpnp_utils_fft.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@ def _copy_array(x, complex_input):
282282
# r2c FFT, if input is integer or float16 dtype, convert to
283283
# float32 or float64 depending on device capabilities
284284
copy_flag = True
285-
dtype = map_dtype_to_device(dpnp.float64, x.sycl_device)
285+
if dtype == dpnp.float16:
286+
dtype = dpnp.float32
287+
else:
288+
dtype = map_dtype_to_device(dpnp.float64, x.sycl_device)
286289

287290
if copy_flag:
288291
x_copy = dpnp.empty_like(x, dtype=dtype, order="C")

dpnp/tests/helper.py

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,19 @@ def assert_dtype_allclose(
8585
assert dpnp_arr.dtype == numpy_arr.dtype
8686

8787

88-
def get_integer_dtypes():
88+
def get_integer_dtypes(no_unsigned=False):
8989
"""
9090
Build a list of integer types supported by DPNP.
9191
"""
9292

93+
dtypes = [dpnp.int32, dpnp.int64]
94+
9395
if config.all_int_types:
94-
return [
95-
dpnp.int8,
96-
dpnp.int16,
97-
dpnp.int32,
98-
dpnp.int64,
99-
dpnp.uint8,
100-
dpnp.uint16,
101-
dpnp.uint32,
102-
dpnp.uint64,
103-
]
96+
dtypes += [dpnp.int8, dpnp.int16]
97+
if not no_unsigned:
98+
dtypes += [dpnp.uint8, dpnp.uint16, dpnp.uint32, dpnp.uint64]
10499

105-
return [dpnp.int32, dpnp.int64]
100+
return dtypes
106101

107102

108103
def get_complex_dtypes(device=None):
@@ -147,17 +142,25 @@ def get_float_complex_dtypes(no_float16=True, device=None):
147142
return dtypes
148143

149144

145+
def get_abs_array(data, dtype=None):
146+
if numpy.issubdtype(dtype, numpy.unsignedinteger):
147+
data = numpy.abs(data)
148+
return numpy.array(data, dtype=dtype)
149+
150+
150151
def get_all_dtypes(
151152
no_bool=False,
152153
no_float16=True,
153154
no_complex=False,
154155
no_none=False,
155-
device=None,
156156
xfail_dtypes=None,
157157
exclude=None,
158+
no_unsigned=False,
159+
device=None,
158160
):
159161
"""
160-
Build a list of types supported by DPNP based on input flags and device capabilities.
162+
Build a list of types supported by DPNP based on
163+
input flags and device capabilities.
161164
"""
162165

163166
dev = dpctl.select_default_device() if device is None else device
@@ -166,7 +169,7 @@ def get_all_dtypes(
166169
dtypes = [dpnp.bool] if not no_bool else []
167170

168171
# add integer types
169-
dtypes.extend(get_integer_dtypes())
172+
dtypes.extend(get_integer_dtypes(no_unsigned=no_unsigned))
170173

171174
# add floating types
172175
dtypes.extend(get_float_dtypes(no_float16=no_float16, device=dev))
@@ -194,7 +197,13 @@ def not_excluded(dtype):
194197

195198

196199
def generate_random_numpy_array(
197-
shape, dtype=None, hermitian=False, seed_value=None, low=-10, high=10
200+
shape,
201+
dtype=None,
202+
order="C",
203+
hermitian=False,
204+
seed_value=None,
205+
low=-10,
206+
high=10,
198207
):
199208
"""
200209
Generate a random numpy array with the specified shape and dtype.
@@ -210,6 +219,9 @@ def generate_random_numpy_array(
210219
Desired data-type for the output array.
211220
If not specified, data type will be determined by numpy.
212221
Default : ``None``
222+
order : {"C", "F"}, optional
223+
Specify the memory layout of the output array.
224+
Default: ``"C"``.
213225
hermitian : bool, optional
214226
If True, generates a Hermitian (symmetric if `dtype` is real) matrix.
215227
Default : ``False``
@@ -226,7 +238,7 @@ def generate_random_numpy_array(
226238
Returns
227239
-------
228240
out : numpy.ndarray
229-
A random numpy array of the specified shape and dtype.
241+
A random numpy array of the specified shape, dtype and memory layout.
230242
The array is Hermitian or symmetric if `hermitian` is True.
231243
232244
Note:
@@ -239,10 +251,13 @@ def generate_random_numpy_array(
239251
seed_value = 42
240252
numpy.random.seed(seed_value)
241253

254+
if numpy.issubdtype(dtype, numpy.unsignedinteger):
255+
low = 0
256+
242257
# dtype=int is needed for 0d arrays
243258
size = numpy.prod(shape, dtype=int)
244259
a = numpy.random.uniform(low, high, size).astype(dtype)
245-
if numpy.issubdtype(a.dtype, numpy.complexfloating):
260+
if numpy.issubdtype(dtype, numpy.complexfloating):
246261
a += 1j * numpy.random.uniform(low, high, size)
247262

248263
a = a.reshape(shape)
@@ -256,6 +271,10 @@ def generate_random_numpy_array(
256271
a = a.reshape(orig_shape)
257272
else:
258273
a = numpy.conj(a.T) @ a
274+
275+
# a.reshape(shape) returns an array in C order by default
276+
if order != "C" and a.ndim > 1:
277+
a = numpy.array(a, order=order)
259278
return a
260279

261280

0 commit comments

Comments
 (0)