Skip to content

Commit 79f8c5c

Browse files
Merge 191688b into df307dd
2 parents df307dd + 191688b commit 79f8c5c

Some content is hidden

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

49 files changed

+1225
-503
lines changed

.github/workflows/conda-package.yml

Lines changed: 241 additions & 5 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,6 +226,116 @@ jobs:
226226
. $CONDA/etc/profile.d/mamba.sh
227227
mamba activate ${{ env.TEST_ENV_NAME }}
228228
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+
extracted-pkg-path: '${{ github.workspace }}/pkg/'
252+
ver-json-path: '${{ github.workspace }}/version.json'
253+
254+
steps:
255+
- name: Download artifact
256+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
257+
with:
258+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
259+
path: ${{ env.pkg-path-in-channel }}
260+
261+
- name: Extract package archive
262+
run: |
263+
mkdir -p ${{ env.extracted-pkg-path }}
264+
tar -xvf ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.tar.bz2 -C ${{ env.extracted-pkg-path }}
265+
266+
- name: Setup miniconda
267+
id: setup_miniconda
268+
continue-on-error: true
269+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
270+
with:
271+
miniforge-version: latest
272+
use-mamba: 'true'
273+
channels: conda-forge
274+
conda-remove-defaults: 'true'
275+
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
276+
activate-environment: ${{ env.TEST_ENV_NAME }}
277+
278+
- name: ReSetup miniconda
279+
if: steps.setup_miniconda.outcome == 'failure'
280+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
281+
with:
282+
miniforge-version: latest
283+
use-mamba: 'true'
284+
channels: conda-forge
285+
conda-remove-defaults: 'true'
286+
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
287+
activate-environment: ${{ env.TEST_ENV_NAME }}
288+
289+
- name: Install conda-index
290+
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
291+
292+
- name: Create conda channel
293+
run: |
294+
python -m conda_index ${{ env.channel-path }}
295+
296+
- name: Test conda channel
297+
run: |
298+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
299+
cat ${{ env.ver-json-path }}
300+
301+
- name: Get package version
302+
run: |
303+
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
304+
305+
echo PACKAGE_VERSION=${PACKAGE_VERSION}
306+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
307+
308+
# conda-index does not support python 3.13
309+
- name: Remove conda-index
310+
run: mamba remove conda-index
311+
312+
- name: Install dpnp
313+
id: install_dpnp
314+
continue-on-error: true
315+
run: |
316+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
317+
env:
318+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
319+
320+
- name: ReInstall dpnp
321+
if: steps.install_dpnp.outcome == 'failure'
322+
run: |
323+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
324+
env:
325+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
326+
327+
- name: List installed packages
328+
run: mamba list
329+
330+
- name: Smoke test
331+
run: |
332+
python -c "import dpctl; dpctl.lsplatform()"
333+
python -c "import dpnp; print(dpnp.__version__)"
334+
335+
- name: Run tests for all dtypes
336+
env:
337+
DPNP_TEST_ALL_INT_TYPES: 1
338+
run: |
229339
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
230340
231341
test_windows:
@@ -319,7 +429,7 @@ jobs:
319429
- name: Install dpnp
320430
run: |
321431
@echo on
322-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
432+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
323433
env:
324434
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
325435
MAMBA_NO_LOW_SPEED_LIMIT: 1
@@ -348,7 +458,7 @@ jobs:
348458
- name: Run tests
349459
if: env.RERUN_TESTS_ON_FAILURE != 'true'
350460
run: |
351-
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
461+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
352462
353463
- name: Run tests
354464
if: env.RERUN_TESTS_ON_FAILURE == 'true'
@@ -359,7 +469,133 @@ jobs:
359469
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
360470
retry_on: any
361471
command: |
362-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
472+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
473+
474+
test_windows_all_dtypes:
475+
name: Test_All_dtypes
476+
477+
needs: build
478+
479+
runs-on: ${{ matrix.os }}
480+
481+
defaults:
482+
run:
483+
shell: cmd /C CALL {0}
484+
485+
strategy:
486+
fail-fast: false
487+
matrix:
488+
python: ['3.12']
489+
os: [windows-2019]
490+
491+
env:
492+
channel-path: '${{ github.workspace }}\channel\'
493+
pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
494+
extracted-pkg-path: '${{ github.workspace }}\pkg'
495+
ver-json-path: '${{ github.workspace }}\version.json'
496+
workdir: '${{ github.workspace }}'
497+
498+
steps:
499+
- name: Download artifact
500+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
501+
with:
502+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
503+
path: ${{ env.pkg-path-in-channel }}
504+
505+
- name: Extract package archive
506+
run: |
507+
@echo on
508+
mkdir -p ${{ env.extracted-pkg-path }}
509+
510+
set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.tar\.bz2""
511+
FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO (
512+
SET FULL_PACKAGE_PATH=%%F
513+
)
514+
echo FULL_PACKAGE_PATH: %FULL_PACKAGE_PATH%
515+
516+
python -c "import shutil; shutil.unpack_archive(r\"%FULL_PACKAGE_PATH%\", extract_dir=r\"${{ env.extracted-pkg-path }}\")"
517+
dir ${{ env.extracted-pkg-path }}
518+
519+
- name: Setup miniconda
520+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
521+
with:
522+
miniforge-version: latest
523+
use-mamba: 'true'
524+
channels: conda-forge
525+
conda-remove-defaults: 'true'
526+
python-version: ${{ env.CONDA_BUILD_INDEX_ENV_PY_VER}}
527+
activate-environment: ${{ env.TEST_ENV_NAME }}
528+
529+
- name: Store conda paths as envs
530+
run: |
531+
@echo on
532+
(echo CONDA_LIB_PATH=%CONDA_PREFIX%\Library\lib\) >> %GITHUB_ENV%
533+
(echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV%
534+
535+
- name: Install conda-index
536+
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
537+
538+
- name: Create conda channel
539+
run: |
540+
@echo on
541+
python -m conda_index ${{ env.channel-path }}
542+
543+
- name: Test conda channel
544+
run: |
545+
@echo on
546+
conda search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
547+
548+
- name: Dump version.json
549+
run: more ${{ env.ver-json-path }}
550+
551+
- name: Get package version
552+
run: |
553+
@echo on
554+
set "SCRIPT=${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}"
555+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
556+
set PACKAGE_VERSION=%%F
557+
)
558+
echo PACKAGE_VERSION: %PACKAGE_VERSION%
559+
(echo PACKAGE_VERSION=%PACKAGE_VERSION%) >> %GITHUB_ENV%
560+
561+
# conda-index does not support python 3.13
562+
- name: Remove conda-index
563+
run: mamba remove conda-index
564+
565+
- name: Install dpnp
566+
run: |
567+
@echo on
568+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
569+
env:
570+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
571+
MAMBA_NO_LOW_SPEED_LIMIT: 1
572+
573+
- name: List installed packages
574+
run: mamba list
575+
576+
- name: Activate OCL CPU RT
577+
shell: pwsh
578+
run: |
579+
$script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
580+
if (Test-Path $script_path) {
581+
&$script_path
582+
} else {
583+
Write-Warning "File $script_path was NOT found!"
584+
}
585+
# Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
586+
$cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
587+
Get-Content -Tail 5 -Path $cl_cfg
588+
589+
- name: Smoke test
590+
run: |
591+
python -c "import dpctl; dpctl.lsplatform()"
592+
python -c "import dpnp; print(dpnp.__version__)"
593+
594+
- name: Run tests for all dtypes
595+
env:
596+
DPNP_TEST_ALL_INT_TYPES: 1
597+
run: |
598+
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
363599
364600
upload:
365601
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)