Skip to content

Commit af80dbe

Browse files
Merge e90eba9 into 2ac196c
2 parents 2ac196c + e90eba9 commit af80dbe

Some content is hidden

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

50 files changed

+1218
-507
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: 234 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ jobs:
189189
id: install_dpnp
190190
continue-on-error: true
191191
run: |
192-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
192+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
193193
env:
194194
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
195195

@@ -211,7 +211,7 @@ jobs:
211211
- name: Run tests
212212
if: env.RERUN_TESTS_ON_FAILURE != 'true'
213213
run: |
214-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
214+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
215215
216216
- name: Run tests
217217
if: env.RERUN_TESTS_ON_FAILURE == 'true'
@@ -226,7 +226,112 @@ jobs:
226226
. $CONDA/etc/profile.d/mamba.sh
227227
mamba activate ${{ env.TEST_ENV_NAME }}
228228
229-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
229+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
230+
231+
test_linux_all_dtypes:
232+
name: Test_All_dtypes
233+
234+
needs: build
235+
236+
runs-on: ${{ matrix.os }}
237+
238+
defaults:
239+
run:
240+
shell: bash -el {0}
241+
242+
strategy:
243+
fail-fast: false
244+
matrix:
245+
python: ['3.12']
246+
os: [ubuntu-latest]
247+
248+
env:
249+
channel-path: '${{ github.workspace }}/channel/'
250+
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
251+
ver-json-path: '${{ github.workspace }}/version.json'
252+
253+
steps:
254+
- name: Download artifact
255+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
256+
with:
257+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
258+
path: ${{ env.pkg-path-in-channel }}
259+
260+
- name: Setup miniconda
261+
id: setup_miniconda
262+
continue-on-error: true
263+
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
264+
with:
265+
miniforge-version: latest
266+
use-mamba: 'true'
267+
channels: conda-forge
268+
conda-remove-defaults: 'true'
269+
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
270+
activate-environment: ${{ env.TEST_ENV_NAME }}
271+
272+
- name: ReSetup miniconda
273+
if: steps.setup_miniconda.outcome == 'failure'
274+
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
275+
with:
276+
miniforge-version: latest
277+
use-mamba: 'true'
278+
channels: conda-forge
279+
conda-remove-defaults: 'true'
280+
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
281+
activate-environment: ${{ env.TEST_ENV_NAME }}
282+
283+
- name: Install conda-index
284+
run: |
285+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
286+
287+
- name: Create conda channel
288+
run: |
289+
python -m conda_index ${{ env.channel-path }}
290+
291+
- name: Test conda channel
292+
run: |
293+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
294+
cat ${{ env.ver-json-path }}
295+
296+
- name: Get package version
297+
run: |
298+
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
299+
300+
echo PACKAGE_VERSION=${PACKAGE_VERSION}
301+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
302+
303+
# conda-index does not support python 3.13
304+
- name: Remove conda-index
305+
run: mamba remove conda-index
306+
307+
- name: Install dpnp
308+
id: install_dpnp
309+
continue-on-error: true
310+
run: |
311+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
312+
env:
313+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
314+
315+
- name: ReInstall dpnp
316+
if: steps.install_dpnp.outcome == 'failure'
317+
run: |
318+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
319+
env:
320+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
321+
322+
- name: List installed packages
323+
run: mamba list
324+
325+
- name: Smoke test
326+
run: |
327+
python -c "import dpctl; dpctl.lsplatform()"
328+
python -c "import dpnp; print(dpnp.__version__)"
329+
330+
- name: Run tests for all dtypes
331+
env:
332+
DPNP_TEST_ALL_INT_TYPES: 1
333+
run: |
334+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
230335
231336
test_windows:
232337
name: Test
@@ -319,7 +424,7 @@ jobs:
319424
- name: Install dpnp
320425
run: |
321426
@echo on
322-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
427+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
323428
env:
324429
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
325430
MAMBA_NO_LOW_SPEED_LIMIT: 1
@@ -348,7 +453,7 @@ jobs:
348453
- name: Run tests
349454
if: env.RERUN_TESTS_ON_FAILURE != 'true'
350455
run: |
351-
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
456+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
352457
353458
- name: Run tests
354459
if: env.RERUN_TESTS_ON_FAILURE == 'true'
@@ -359,7 +464,130 @@ jobs:
359464
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
360465
retry_on: any
361466
command: |
362-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
467+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
468+
469+
test_windows_all_dtypes:
470+
name: Test_All_dtypes
471+
472+
needs: build
473+
474+
runs-on: ${{ matrix.os }}
475+
476+
defaults:
477+
run:
478+
shell: cmd /C CALL {0}
479+
480+
strategy:
481+
fail-fast: false
482+
matrix:
483+
python: ['3.12']
484+
os: [windows-2019]
485+
486+
env:
487+
channel-path: '${{ github.workspace }}\channel\'
488+
pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
489+
ver-json-path: '${{ github.workspace }}\version.json'
490+
workdir: '${{ github.workspace }}'
491+
492+
steps:
493+
- name: Download artifact
494+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
495+
with:
496+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
497+
path: ${{ env.pkg-path-in-channel }}
498+
499+
- name: Store a path to package archive
500+
run: |
501+
@echo on
502+
503+
set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.conda""
504+
FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO (
505+
SET FULL_PACKAGE_PATH=%%F
506+
)
507+
echo FULL_PACKAGE_PATH: %FULL_PACKAGE_PATH%
508+
(echo FULL_PACKAGE_PATH=%FULL_PACKAGE_PATH%) >> %GITHUB_ENV%
509+
510+
- name: Setup miniconda
511+
uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3.1.1
512+
with:
513+
miniforge-version: latest
514+
use-mamba: 'true'
515+
channels: conda-forge
516+
conda-remove-defaults: 'true'
517+
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
518+
activate-environment: ${{ env.TEST_ENV_NAME }}
519+
520+
- name: Store conda paths as envs
521+
run: |
522+
@echo on
523+
(echo CONDA_LIB_PATH=%CONDA_PREFIX%\Library\lib\) >> %GITHUB_ENV%
524+
(echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV%
525+
526+
- name: Install conda-index
527+
run: |
528+
mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
529+
530+
- name: Create conda channel
531+
run: |
532+
@echo on
533+
python -m conda_index ${{ env.channel-path }}
534+
535+
- name: Test conda channel
536+
run: |
537+
@echo on
538+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
539+
540+
- name: Dump version.json
541+
run: more ${{ env.ver-json-path }}
542+
543+
- name: Get package version
544+
run: |
545+
@echo on
546+
set "SCRIPT=${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}"
547+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
548+
set PACKAGE_VERSION=%%F
549+
)
550+
echo PACKAGE_VERSION: %PACKAGE_VERSION%
551+
(echo PACKAGE_VERSION=%PACKAGE_VERSION%) >> %GITHUB_ENV%
552+
553+
# conda-index does not support python 3.13
554+
- name: Remove conda-index
555+
run: mamba remove conda-index
556+
557+
- name: Install dpnp
558+
run: |
559+
@echo on
560+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
561+
env:
562+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
563+
MAMBA_NO_LOW_SPEED_LIMIT: 1
564+
565+
- name: List installed packages
566+
run: mamba list
567+
568+
- name: Activate OCL CPU RT
569+
shell: pwsh
570+
run: |
571+
$script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
572+
if (Test-Path $script_path) {
573+
&$script_path
574+
} else {
575+
Write-Warning "File $script_path was NOT found!"
576+
}
577+
# Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
578+
$cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
579+
Get-Content -Tail 5 -Path $cl_cfg
580+
581+
- name: Smoke test
582+
run: |
583+
python -c "import dpctl; dpctl.lsplatform()"
584+
python -c "import dpnp; print(dpnp.__version__)"
585+
586+
- name: Run tests for all dtypes
587+
env:
588+
DPNP_TEST_ALL_INT_TYPES: 1
589+
run: |
590+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
363591
364592
upload:
365593
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)

0 commit comments

Comments
 (0)