Skip to content

Commit a098910

Browse files
Add integer dtypes (int8,int16, uint8-uint64) to dpnp interface
Add missing aliases to integer types: [u]byte, ushort, [u]longlong Not adding [u]long aliases as it is removed from NumPy (https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations) Removed int alias as it is depricate in NumPy Extend tests types matrix by these types Add environment variable DPNP_TEST_ALL_TYPES to enable/disable these types in tests Failing dpnp tests: test_arraycreation.py::test_geomspace test_arraycreation.py::test_linspace test_arraycreation.py::test_logspace test_fft.py::TestFft2::test_fft2 test_fft.py::TestRfft2::test_rfft2 test_histogram.py::TestDigitize::test_digitize test_indexing.py::TestPut::test_input_1d test_indexing.py::TestPut::test_input_2d test_indexing.py::TestPutAlongAxis::test_replace_max test_indexing.py::TestTake::test_1d test_indexing.py::TestTake::test_2d test_indexing.py::TestTakeAlongAxis::test_broadcast test_indexing.py::TestTakeAlongAxis::test_empty test_indexing.py::TestTakeAlongAxis::test_empty test_indexing.py::TestTakeAlongAxis::test_multi_dimensions test_linalg.py::TestCond::test_cond test_linalg.py::TestEigenvalue::test_eigenvalues test_linalg.py::TestLstsq::test_lstsq_diff_type test_linalg.py::TestNorm::test_norm_1D test_linalg.py::TestNorm::test_norm_2D test_linalg.py::TestNorm::test_norm_ND test_linalg.py::TestNorm::test_norm_usm_ndarray test_linalg.py::TestPinv::test_pinv test_linalg.py::TestQr::test_qr test_linalg.py::TestSvd::test_svd test_manipulation.py::TestUnique::test_2d_axis_signed_inetger test_manipulation.py::test_copyto_dtype test_mathematical.py::TestAngle::test_angle test_mathematical.py::TestCumLogSumExp::test_basic test_mathematical.py::TestCumProd::test_out_dtype test_mathematical.py::TestCumSum::test_out_dtype test_mathematical.py::TestFix::test_basic test_mathematical.py::TestFix::test_out test_mathematical.py::TestHypot::test_hypot test_mathematical.py::TestLogSumExp::test_logsumexp test_mathematical.py::TestLogSumExp::test_logsumexp_dtype test_mathematical.py::TestLogSumExp::test_logsumexp_out test_mathematical.py::TestLogSumExp::test_logsumexp_out_dtype test_mathematical.py::TestMathematical::test_remainder test_mathematical.py::TestMatmul::test_matmul_axes_ND_ND test_mathematical.py::TestMatmul::test_matmul_axes_out test_mathematical.py::TestMatmul::test_matmul_dtype test_mathematical.py::TestMatmul::test_matmul_dtype_matrix_inout test_mathematical.py::TestMatmul::test_matmul_dtype_matrix_inputs test_mathematical.py::TestMatmul::test_matmul_out1 test_mathematical.py::TestMatmul::test_matmul_out2 test_mathematical.py::TestPower::test_basic test_mathematical.py::TestProd::test_prod_out_dtype test_mathematical.py::TestReduceHypot::test_reduce_hypot test_mathematical.py::TestReduceHypot::test_reduce_hypot_dtype test_mathematical.py::TestReduceHypot::test_reduce_hypot_out test_mathematical.py::TestUnwrap::test_discont test_mathematical.py::TestUnwrap::test_rand_period test_nanfunctions.py::TestNanProd::test_nanprod_out_dtype test_product.py::TestDot::test_dot test_product.py::TestDot::test_dot_ndarray test_product.py::TestDot::test_dot_out test_product.py::TestDot::test_dot_out_scalar test_product.py::TestDot::test_dot_scalar test_product.py::TestInner::test_inner test_product.py::TestInner::test_inner_scalar test_product.py::TestKron::test_kron_scalar test_product.py::TestMultiDot::test_multi_dot test_product.py::TestMultiDot::test_multi_dot_all_2d test_product.py::TestMultiDot::test_multi_dot_out test_product.py::TestTensordot::test_tensordot test_product.py::TestTensordot::test_tensordot_axes test_product.py::TestTensordot::test_tensordot_input_dtype_matrix test_product.py::TestTensordot::test_tensordot_scalar test_sort.py::test_partition test_statistics.py::TestAverage::test_avg test_statistics.py::TestAverage::test_avg_strided test_statistics.py::TestStd::test_std_strided test_statistics.py::TestVar::test_var_strided test_statistics.py::test_median test_strides.py::test_cumlogsumexp test_strides.py::test_logsumexp test_strides.py::test_reduce_hypot test_strides.py::test_strides_erf test_sum.py::test_sum test_umath.py::TestArctan2::test_arctan2 test_umath.py::TestCbrt::test_cbrt test_umath.py::TestCopySign::test_copysign test_umath.py::TestFloatPower::test_negative_base_value_complex_dtype test_umath.py::TestLogAddExp::test_logaddexp test_umath.py::TestRsqrt::test_rsqrt test_umath.py::TestUmath::test_out
1 parent d83ea3d commit a098910

File tree

12 files changed

+415
-50
lines changed

12 files changed

+415
-50
lines changed

.github/workflows/conda-package.yml

Lines changed: 213 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ jobs:
159159
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
160160
161161
- name: Install dpnp
162-
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
162+
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
163163
env:
164164
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
165165
MAMBA_NO_LOW_SPEED_LIMIT: 1
@@ -175,7 +175,7 @@ jobs:
175175
- name: Run tests
176176
if: env.RERUN_TESTS_ON_FAILURE != 'true'
177177
run: |
178-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
178+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
179179
180180
- name: Run tests
181181
if: env.RERUN_TESTS_ON_FAILURE == 'true'
@@ -190,7 +190,91 @@ jobs:
190190
. $CONDA/etc/profile.d/mamba.sh
191191
mamba activate ${{ env.TEST_ENV_NAME }}
192192
193-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
193+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
194+
195+
test_linux_all_dtypes:
196+
name: Test ['ubuntu-latest', python='${{ matrix.python }}']
197+
198+
needs: build
199+
200+
runs-on: ubuntu-latest
201+
202+
defaults:
203+
run:
204+
shell: bash -el {0}
205+
206+
strategy:
207+
matrix:
208+
python: ['3.12']
209+
210+
continue-on-error: true
211+
212+
env:
213+
channel-path: '${{ github.workspace }}/channel/'
214+
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
215+
extracted-pkg-path: '${{ github.workspace }}/pkg/'
216+
ver-json-path: '${{ github.workspace }}/version.json'
217+
218+
steps:
219+
- name: Download artifact
220+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
221+
with:
222+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
223+
path: ${{ env.pkg-path-in-channel }}
224+
225+
- name: Extract package archive
226+
run: |
227+
mkdir -p ${{ env.extracted-pkg-path }}
228+
tar -xvf ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.tar.bz2 -C ${{ env.extracted-pkg-path }}
229+
230+
- name: Setup miniconda
231+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
232+
with:
233+
miniforge-version: latest
234+
use-mamba: 'true'
235+
channels: conda-forge
236+
conda-remove-defaults: 'true'
237+
python-version: ${{ matrix.python }}
238+
activate-environment: ${{ env.TEST_ENV_NAME }}
239+
240+
- name: Install conda-index
241+
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
242+
243+
- name: Create conda channel
244+
run: |
245+
python -m conda_index ${{ env.channel-path }}
246+
247+
- name: Test conda channel
248+
run: |
249+
mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
250+
cat ${{ env.ver-json-path }}
251+
252+
- name: Get package version
253+
run: |
254+
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
255+
256+
echo PACKAGE_VERSION=${PACKAGE_VERSION}
257+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
258+
259+
- name: Install dpnp
260+
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
261+
env:
262+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
263+
MAMBA_NO_LOW_SPEED_LIMIT: 1
264+
265+
- name: List installed packages
266+
run: mamba list
267+
268+
- name: Smoke test
269+
run: |
270+
python -c "import dpnp, dpctl; dpctl.lsplatform()"
271+
python -c "import dpnp; print(dpnp.__version__)"
272+
273+
- name: Run full tests
274+
env:
275+
DPNP_TEST_ALL_INT_TYPES: 1
276+
run: |
277+
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
194278
195279
test_windows:
196280
name: Test ['windows-2019', python='${{ matrix.python }}']
@@ -282,7 +366,7 @@ jobs:
282366
- name: Install dpnp
283367
run: |
284368
@echo on
285-
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
369+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
286370
env:
287371
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
288372
MAMBA_NO_LOW_SPEED_LIMIT: 1
@@ -311,7 +395,7 @@ jobs:
311395
- name: Run tests
312396
if: env.RERUN_TESTS_ON_FAILURE != 'true'
313397
run: |
314-
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
398+
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
315399
316400
- name: Run tests
317401
if: env.RERUN_TESTS_ON_FAILURE == 'true'
@@ -322,7 +406,130 @@ jobs:
322406
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
323407
retry_on: any
324408
command: |
325-
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
409+
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
410+
411+
test_windows_all_dtypes:
412+
name: Test ['windows-2019', python='${{ matrix.python }}']
413+
414+
needs: build
415+
416+
runs-on: windows-2019
417+
418+
defaults:
419+
run:
420+
shell: cmd /C CALL {0}
421+
422+
strategy:
423+
matrix:
424+
python: ['3.12']
425+
426+
continue-on-error: true
427+
428+
env:
429+
channel-path: '${{ github.workspace }}\channel\'
430+
pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
431+
extracted-pkg-path: '${{ github.workspace }}\pkg'
432+
ver-json-path: '${{ github.workspace }}\version.json'
433+
workdir: '${{ github.workspace }}'
434+
435+
steps:
436+
- name: Download artifact
437+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
438+
with:
439+
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
440+
path: ${{ env.pkg-path-in-channel }}
441+
442+
- name: Extract package archive
443+
run: |
444+
@echo on
445+
mkdir -p ${{ env.extracted-pkg-path }}
446+
447+
set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.tar\.bz2""
448+
FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO (
449+
SET FULL_PACKAGE_PATH=%%F
450+
)
451+
echo FULL_PACKAGE_PATH: %FULL_PACKAGE_PATH%
452+
453+
python -c "import shutil; shutil.unpack_archive(r\"%FULL_PACKAGE_PATH%\", extract_dir=r\"${{ env.extracted-pkg-path }}\")"
454+
dir ${{ env.extracted-pkg-path }}
455+
456+
- name: Setup miniconda
457+
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
458+
with:
459+
miniforge-version: latest
460+
use-mamba: 'true'
461+
channels: conda-forge
462+
conda-remove-defaults: 'true'
463+
python-version: ${{ matrix.python }}
464+
activate-environment: ${{ env.TEST_ENV_NAME }}
465+
466+
- name: Store conda paths as envs
467+
run: |
468+
@echo on
469+
(echo CONDA_LIB_PATH=%CONDA_PREFIX%\Library\lib\) >> %GITHUB_ENV%
470+
(echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV%
471+
472+
- name: Install conda-index
473+
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}
474+
475+
- name: Create conda channel
476+
run: |
477+
@echo on
478+
python -m conda_index ${{ env.channel-path }}
479+
480+
- name: Test conda channel
481+
run: |
482+
@echo on
483+
mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
484+
485+
- name: Dump version.json
486+
run: more ${{ env.ver-json-path }}
487+
488+
- name: Get package version
489+
run: |
490+
@echo on
491+
set "SCRIPT=${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}"
492+
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
493+
set PACKAGE_VERSION=%%F
494+
)
495+
echo PACKAGE_VERSION: %PACKAGE_VERSION%
496+
(echo PACKAGE_VERSION=%PACKAGE_VERSION%) >> %GITHUB_ENV%
497+
498+
- name: Install dpnp
499+
run: |
500+
@echo on
501+
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
502+
env:
503+
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
504+
MAMBA_NO_LOW_SPEED_LIMIT: 1
505+
506+
- name: List installed packages
507+
run: mamba list
508+
509+
- name: Activate OCL CPU RT
510+
shell: pwsh
511+
run: |
512+
$script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
513+
if (Test-Path $script_path) {
514+
&$script_path
515+
} else {
516+
Write-Warning "File $script_path was NOT found!"
517+
}
518+
# Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
519+
$cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
520+
Get-Content -Tail 5 -Path $cl_cfg
521+
522+
- name: Smoke test
523+
run: |
524+
python -c "import dpnp, dpctl; dpctl.lsplatform()"
525+
python -c "import dpnp; print(dpnp.__version__)"
526+
527+
- name: Run full tests
528+
if: matrix.python == '3.12'
529+
env:
530+
DPNP_TEST_ALL_INT_TYPES: 1
531+
run: |
532+
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
326533
327534
upload:
328535
name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']

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_iface_types.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
__all__ = [
4141
"bool",
4242
"bool_",
43+
"byte",
4344
"cdouble",
4445
"complex128",
4546
"complex64",
@@ -57,21 +58,34 @@
5758
"iinfo",
5859
"inexact",
5960
"inf",
60-
"int",
6161
"int_",
62+
"int8",
63+
"int16",
6264
"int32",
6365
"int64",
6466
"integer",
6567
"intc",
6668
"intp",
6769
"issubdtype",
6870
"is_type_supported",
71+
"longlong",
6972
"nan",
7073
"newaxis",
7174
"number",
7275
"pi",
76+
"short",
7377
"signedinteger",
7478
"single",
79+
"ubyte",
80+
"uint8",
81+
"uint16",
82+
"uint32",
83+
"uint64",
84+
"uintc",
85+
"uintp",
86+
"unsignedinteger",
87+
"ushort",
88+
"ulonglong",
7589
]
7690

7791

@@ -81,6 +95,7 @@
8195
# =============================================================================
8296
bool = numpy.bool_
8397
bool_ = numpy.bool_
98+
byte = numpy.byte
8499
cdouble = numpy.cdouble
85100
complex128 = numpy.complex128
86101
complex64 = numpy.complex64
@@ -93,16 +108,29 @@
93108
float64 = numpy.float64
94109
floating = numpy.floating
95110
inexact = numpy.inexact
96-
int = numpy.int_
97111
int_ = numpy.int_
112+
int8 = numpy.int8
113+
int16 = numpy.int16
98114
int32 = numpy.int32
99115
int64 = numpy.int64
100116
integer = numpy.integer
101117
intc = numpy.intc
102118
intp = numpy.intp
119+
longlong = numpy.longlong
103120
number = numpy.number
121+
short = numpy.short
104122
signedinteger = numpy.signedinteger
105123
single = numpy.single
124+
ubyte = numpy.ubyte
125+
uint8 = numpy.uint8
126+
uint16 = numpy.uint16
127+
uint32 = numpy.uint32
128+
uint64 = numpy.uint64
129+
uintc = numpy.uintc
130+
uintp = numpy.uintp
131+
unsignedinteger = numpy.unsignedinteger
132+
ushort = numpy.ushort
133+
ulonglong = numpy.ulonglong
106134

107135

108136
# =============================================================================

dpnp/tests/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import os
2+
3+
all_int_types = int(os.getenv("DPNP_TEST_ALL_INT_TYPES", 0))
4+
float16_types = int(os.getenv("DPNP_TEST_FLOAT_16", 0))
5+
complex_types = int(os.getenv("DPNP_TEST_COMPLEX_TYPES", 0))
6+
bool_types = int(os.getenv("DPNP_TEST_BOOL_TYPES", 0))

0 commit comments

Comments
 (0)