Skip to content

Commit 9151a9a

Browse files
Merge master into support_onemath
2 parents 974b5a0 + 93535bd commit 9151a9a

Some content is hidden

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

66 files changed

+1728
-833
lines changed

.github/workflows/array-api-skips.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# array API tests to be skipped
22

3-
# no 'uint8' dtype
4-
array_api_tests/test_array_object.py::test_getitem_masking
5-
63
# missing unique-like functions
74
array_api_tests/test_has_names.py::test_has_names[set-unique_all]
85
array_api_tests/test_has_names.py::test_has_names[set-unique_counts]

.github/workflows/conda-package.yml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
CONDA_BUILD_INDEX_ENV_PY_VER: '3.12' # conda does not support python 3.13
1717
CONDA_BUILD_VERSION: '25.1.1'
1818
CONDA_INDEX_VERSION: '0.5.0'
19+
LATEST_PYTHON: '3.13'
1920
RERUN_TESTS_ON_FAILURE: 'true'
2021
RUN_TESTS_MAX_ATTEMPTS: 2
2122
TEST_ENV_NAME: 'test'
@@ -189,7 +190,7 @@ jobs:
189190
id: install_dpnp
190191
continue-on-error: true
191192
run: |
192-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
193+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
193194
env:
194195
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
195196

@@ -211,22 +212,32 @@ jobs:
211212
- name: Run tests
212213
if: env.RERUN_TESTS_ON_FAILURE != 'true'
213214
run: |
214-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
215+
if [[ ${{ matrix.python }} == ${{ env.LATEST_PYTHON }} ]]; then
216+
export DPNP_TEST_ALL_INT_TYPES=1
217+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
218+
else
219+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
220+
fi
215221
216222
- name: Run tests
217223
if: env.RERUN_TESTS_ON_FAILURE == 'true'
218224
id: run_tests_linux
219225
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
220226
with:
221-
timeout_minutes: 15
227+
timeout_minutes: 25
222228
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
223229
retry_on: any
224230
command: |
225231
. $CONDA/etc/profile.d/conda.sh
226232
. $CONDA/etc/profile.d/mamba.sh
227233
mamba activate ${{ env.TEST_ENV_NAME }}
228234
229-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
235+
if [[ ${{ matrix.python }} == ${{ env.LATEST_PYTHON }} ]]; then
236+
export DPNP_TEST_ALL_INT_TYPES=1
237+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
238+
else
239+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
240+
fi
230241
231242
test_windows:
232243
name: Test
@@ -319,7 +330,7 @@ jobs:
319330
- name: Install dpnp
320331
run: |
321332
@echo on
322-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
333+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
323334
env:
324335
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
325336
MAMBA_NO_LOW_SPEED_LIMIT: 1
@@ -348,18 +359,28 @@ jobs:
348359
- name: Run tests
349360
if: env.RERUN_TESTS_ON_FAILURE != 'true'
350361
run: |
351-
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
362+
if (${{ matrix.python }} -eq ${{ env.LATEST_PYTHON }}) {
363+
set DPNP_TEST_ALL_INT_TYPES=1
364+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
365+
} else {
366+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
367+
}
352368
353369
- name: Run tests
354370
if: env.RERUN_TESTS_ON_FAILURE == 'true'
355371
id: run_tests_win
356372
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
357373
with:
358-
timeout_minutes: 17
374+
timeout_minutes: 35
359375
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
360376
retry_on: any
361377
command: |
362-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
378+
if ( ${{ matrix.python }} -eq ${{ env.LATEST_PYTHON }} ) {
379+
set DPNP_TEST_ALL_INT_TYPES=1
380+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
381+
} else {
382+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
383+
}
363384
364385
upload:
365386
name: Upload

doc/reference/dtypes_table.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,35 @@ Table below shows a list of all supported data types (dtypes) and constants of t
1313
- Constants
1414
* -
1515
- :obj:`bool <numpy.bool_>`
16+
- :obj:`int8 <numpy.int8>`
17+
- :obj:`int16 <numpy.int16>`
1618
- :obj:`int32 <numpy.int32>`
1719
- :obj:`int64 <numpy.int64>`
20+
- :obj:`uint8 <numpy.uint8>`
21+
- :obj:`uint16 <numpy.uint16>`
22+
- :obj:`uint32 <numpy.uint32>`
23+
- :obj:`uint64 <numpy.uint64>`
1824
- :obj:`float32 <numpy.float32>`
1925
- :obj:`float64 <numpy.float64>`
2026
- :obj:`complex64 <numpy.complex64>`
2127
- :obj:`complex128 <numpy.complex128>`
2228
-
2329
- :obj:`bool_ <numpy.bool_>`
30+
- :obj:`byte <numpy.byte>`
2431
- :obj:`cdouble <numpy.cdouble>`
2532
- :obj:`csingle <numpy.csingle>`
2633
- :obj:`double <numpy.double>`
2734
- :obj:`float16 <numpy.float16>`
28-
- :obj:`int <numpy.int>`
2935
- :obj:`int_ <numpy.int_>`
3036
- :obj:`intc <numpy.intc>`
37+
- :obj:`intp <numpy.intp>`
38+
- :obj:`longlong <numpy.longlong>`
3139
- :obj:`single <numpy.single>`
40+
- :obj:`ubyte <numpy.ubyte>`
41+
- :obj:`uintc <numpy.uintc>`
42+
- :obj:`uintp <numpy.uintp>`
43+
- :obj:`ushort <numpy.ushort>`
44+
- :obj:`ulonglong <numpy.ulonglong>`
3245
-
3346
- :obj:`e <numpy.e>`
3447
- :obj:`euler_gamma <numpy.euler_gamma>`

dpnp/dpnp_algo/dpnp_elementwise_common.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -600,12 +600,18 @@ def __init__(
600600
def __call__(self, x, decimals=0, out=None, dtype=None):
601601
if decimals != 0:
602602
x_usm = dpnp.get_usm_ndarray(x)
603-
if dpnp.issubdtype(x_usm.dtype, dpnp.integer) and dtype is None:
604-
dtype = x_usm.dtype
605-
606603
out_usm = None if out is None else dpnp.get_usm_ndarray(out)
607-
x_usm = dpt.round(x_usm * 10**decimals, out=out_usm)
608-
res_usm = dpt.divide(x_usm, 10**decimals, out=out_usm)
604+
605+
if dpnp.issubdtype(x_usm.dtype, dpnp.integer):
606+
if decimals < 0:
607+
dtype = x_usm.dtype
608+
x_usm = dpt.round(x_usm * 10**decimals, out=out_usm)
609+
res_usm = dpt.divide(x_usm, 10**decimals, out=out_usm)
610+
else:
611+
res_usm = dpt.round(x_usm, out=out_usm)
612+
else:
613+
x_usm = dpt.round(x_usm * 10**decimals, out=out_usm)
614+
res_usm = dpt.divide(x_usm, 10**decimals, out=out_usm)
609615

610616
if dtype is not None:
611617
res_usm = dpt.astype(res_usm, dtype, copy=False)

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,
@@ -66,6 +68,20 @@
6668
]
6769

6870

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

141157
if dpnp.isscalar(a) or dpnp.isscalar(b):
142-
# TODO: use specific scalar-vector kernel
143-
return dpnp.multiply(a, b, out=out)
158+
return _call_multiply(a, b, out=out)
144159

145160
a_ndim = a.ndim
146161
b_ndim = b.ndim
@@ -635,8 +650,7 @@ def inner(a, b):
635650
dpnp.check_supported_arrays_type(a, b, scalar_type=True)
636651

637652
if dpnp.isscalar(a) or dpnp.isscalar(b):
638-
# TODO: use specific scalar-vector kernel
639-
return dpnp.multiply(a, b)
653+
return _call_multiply(a, b)
640654

641655
if a.ndim == 0 or b.ndim == 0:
642656
# TODO: use specific scalar-vector kernel
@@ -714,8 +728,7 @@ def kron(a, b):
714728
dpnp.check_supported_arrays_type(a, b, scalar_type=True)
715729

716730
if dpnp.isscalar(a) or dpnp.isscalar(b):
717-
# TODO: use specific scalar-vector kernel
718-
return dpnp.multiply(a, b)
731+
return _call_multiply(a, b)
719732

720733
a_ndim = a.ndim
721734
b_ndim = b.ndim
@@ -1199,8 +1212,7 @@ def tensordot(a, b, axes=2):
11991212
raise ValueError(
12001213
"One of the inputs is scalar, axes should be zero."
12011214
)
1202-
# TODO: use specific scalar-vector kernel
1203-
return dpnp.multiply(a, b)
1215+
return _call_multiply(a, b)
12041216

12051217
return dpnp_tensordot(a, b, axes=axes)
12061218

@@ -1263,13 +1275,13 @@ def vdot(a, b):
12631275
if b.size != 1:
12641276
raise ValueError("The second array should be of size one.")
12651277
a_conj = numpy.conj(a)
1266-
return dpnp.multiply(a_conj, b)
1278+
return _call_multiply(a_conj, b)
12671279

12681280
if dpnp.isscalar(b):
12691281
if a.size != 1:
12701282
raise ValueError("The first array should be of size one.")
12711283
a_conj = dpnp.conj(a)
1272-
return dpnp.multiply(a_conj, b)
1284+
return _call_multiply(a_conj, b)
12731285

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

dpnp/dpnp_iface_manipulation.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,20 @@ def copyto(dst, src, casting="same_kind", where=True):
14941494
f"but got {type(dst)}"
14951495
)
14961496
if not dpnp.is_supported_array_type(src):
1497+
no_dtype_attr = not hasattr(src, "dtype")
14971498
src = dpnp.array(src, sycl_queue=dst.sycl_queue)
1499+
if no_dtype_attr:
1500+
# This case (scalar, list, etc) needs special handling to
1501+
# behave similar to NumPy
1502+
if dpnp.issubdtype(src, dpnp.integer) and dpnp.issubdtype(
1503+
dst, dpnp.unsignedinteger
1504+
):
1505+
if dpnp.any(src < 0):
1506+
raise OverflowError(
1507+
"Cannot copy negative values to an unsigned int array"
1508+
)
1509+
1510+
src = src.astype(dst.dtype)
14981511

14991512
if not dpnp.can_cast(src.dtype, dst.dtype, casting=casting):
15001513
raise TypeError(

0 commit comments

Comments
 (0)