Skip to content

Commit

Permalink
Add integer dtypes (int8,int16, uint8-uint64) to dpnp interface
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AlexanderKalistratov committed Dec 11, 2024
1 parent d83ea3d commit a098910
Show file tree
Hide file tree
Showing 12 changed files with 415 additions and 50 deletions.
219 changes: 213 additions & 6 deletions .github/workflows/conda-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Install dpnp
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
MAMBA_NO_LOW_SPEED_LIMIT: 1
Expand All @@ -175,7 +175,7 @@ jobs:
- name: Run tests
if: env.RERUN_TESTS_ON_FAILURE != 'true'
run: |
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
- name: Run tests
if: env.RERUN_TESTS_ON_FAILURE == 'true'
Expand All @@ -190,7 +190,91 @@ jobs:
. $CONDA/etc/profile.d/mamba.sh
mamba activate ${{ env.TEST_ENV_NAME }}
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
test_linux_all_dtypes:
name: Test ['ubuntu-latest', python='${{ matrix.python }}']

needs: build

runs-on: ubuntu-latest

defaults:
run:
shell: bash -el {0}

strategy:
matrix:
python: ['3.12']

continue-on-error: true

env:
channel-path: '${{ github.workspace }}/channel/'
pkg-path-in-channel: '${{ github.workspace }}/channel/linux-64/'
extracted-pkg-path: '${{ github.workspace }}/pkg/'
ver-json-path: '${{ github.workspace }}/version.json'

steps:
- name: Download artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.pkg-path-in-channel }}

- name: Extract package archive
run: |
mkdir -p ${{ env.extracted-pkg-path }}
tar -xvf ${{ env.pkg-path-in-channel }}/${{ env.PACKAGE_NAME }}-*.tar.bz2 -C ${{ env.extracted-pkg-path }}
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
with:
miniforge-version: latest
use-mamba: 'true'
channels: conda-forge
conda-remove-defaults: 'true'
python-version: ${{ matrix.python }}
activate-environment: ${{ env.TEST_ENV_NAME }}

- name: Install conda-index
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}

- name: Create conda channel
run: |
python -m conda_index ${{ env.channel-path }}
- name: Test conda channel
run: |
mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
cat ${{ env.ver-json-path }}
- name: Get package version
run: |
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
echo PACKAGE_VERSION=${PACKAGE_VERSION}
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
- name: Install dpnp
run: mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
MAMBA_NO_LOW_SPEED_LIMIT: 1

- name: List installed packages
run: mamba list

- name: Smoke test
run: |
python -c "import dpnp, dpctl; dpctl.lsplatform()"
python -c "import dpnp; print(dpnp.__version__)"
- name: Run full tests
env:
DPNP_TEST_ALL_INT_TYPES: 1
run: |
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
test_windows:
name: Test ['windows-2019', python='${{ matrix.python }}']
Expand Down Expand Up @@ -282,7 +366,7 @@ jobs:
- name: Install dpnp
run: |
@echo on
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
MAMBA_NO_LOW_SPEED_LIMIT: 1
Expand Down Expand Up @@ -311,7 +395,7 @@ jobs:
- name: Run tests
if: env.RERUN_TESTS_ON_FAILURE != 'true'
run: |
pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
- name: Run tests
if: env.RERUN_TESTS_ON_FAILURE == 'true'
Expand All @@ -322,7 +406,130 @@ jobs:
max_attempts: ${{ env.RUN_TESTS_MAX_ATTEMPTS }}
retry_on: any
command: |
python -m pytest -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
python -m pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
test_windows_all_dtypes:
name: Test ['windows-2019', python='${{ matrix.python }}']

needs: build

runs-on: windows-2019

defaults:
run:
shell: cmd /C CALL {0}

strategy:
matrix:
python: ['3.12']

continue-on-error: true

env:
channel-path: '${{ github.workspace }}\channel\'
pkg-path-in-channel: '${{ github.workspace }}\channel\win-64\'
extracted-pkg-path: '${{ github.workspace }}\pkg'
ver-json-path: '${{ github.workspace }}\version.json'
workdir: '${{ github.workspace }}'

steps:
- name: Download artifact
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python }}
path: ${{ env.pkg-path-in-channel }}

- name: Extract package archive
run: |
@echo on
mkdir -p ${{ env.extracted-pkg-path }}
set SEARCH_SCRIPT="DIR ${{ env.pkg-path-in-channel }} /s/b | FINDSTR /r "dpnp-.*\.tar\.bz2""
FOR /F "tokens=* USEBACKQ" %%F IN (`%SEARCH_SCRIPT%`) DO (
SET FULL_PACKAGE_PATH=%%F
)
echo FULL_PACKAGE_PATH: %FULL_PACKAGE_PATH%
python -c "import shutil; shutil.unpack_archive(r\"%FULL_PACKAGE_PATH%\", extract_dir=r\"${{ env.extracted-pkg-path }}\")"
dir ${{ env.extracted-pkg-path }}
- name: Setup miniconda
uses: conda-incubator/setup-miniconda@d2e6a045a86077fb6cad6f5adf368e9076ddaa8d # v3.1.0
with:
miniforge-version: latest
use-mamba: 'true'
channels: conda-forge
conda-remove-defaults: 'true'
python-version: ${{ matrix.python }}
activate-environment: ${{ env.TEST_ENV_NAME }}

- name: Store conda paths as envs
run: |
@echo on
(echo CONDA_LIB_PATH=%CONDA_PREFIX%\Library\lib\) >> %GITHUB_ENV%
(echo CONDA_LIB_BIN_PATH=%CONDA_PREFIX%\Library\bin\) >> %GITHUB_ENV%
- name: Install conda-index
run: mamba install conda-index=${{ env.CONDA_INDEX_VERSION }}

- name: Create conda channel
run: |
@echo on
python -m conda_index ${{ env.channel-path }}
- name: Test conda channel
run: |
@echo on
mamba search ${{ env.PACKAGE_NAME }} -c ${{ env.channel-path }} --override-channels --info --json > ${{ env.ver-json-path }}
- name: Dump version.json
run: more ${{ env.ver-json-path }}

- name: Get package version
run: |
@echo on
set "SCRIPT=${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}"
FOR /F "tokens=* USEBACKQ" %%F IN (`python -c "%SCRIPT%"`) DO (
set PACKAGE_VERSION=%%F
)
echo PACKAGE_VERSION: %PACKAGE_VERSION%
(echo PACKAGE_VERSION=%PACKAGE_VERSION%) >> %GITHUB_ENV%
- name: Install dpnp
run: |
@echo on
mamba install ${{ env.PACKAGE_NAME }}=${{ env.PACKAGE_VERSION }} pytest pytest-xdist python=${{ matrix.python }} ${{ env.TEST_CHANNELS }}
env:
TEST_CHANNELS: '-c ${{ env.channel-path }} ${{ env.CHANNELS }}'
MAMBA_NO_LOW_SPEED_LIMIT: 1

- name: List installed packages
run: mamba list

- name: Activate OCL CPU RT
shell: pwsh
run: |
$script_path="$env:CONDA_PREFIX\Scripts\set-intel-ocl-icd-registry.ps1"
if (Test-Path $script_path) {
&$script_path
} else {
Write-Warning "File $script_path was NOT found!"
}
# Check the variable assisting OpenCL CPU driver to find TBB DLLs which are not located where it expects them by default
$cl_cfg="$env:CONDA_PREFIX\Library\lib\cl.cfg"
Get-Content -Tail 5 -Path $cl_cfg
- name: Smoke test
run: |
python -c "import dpnp, dpctl; dpctl.lsplatform()"
python -c "import dpnp; print(dpnp.__version__)"
- name: Run full tests
if: matrix.python == '3.12'
env:
DPNP_TEST_ALL_INT_TYPES: 1
run: |
pytest -n auto -ra --pyargs ${{ env.PACKAGE_NAME }}.tests
upload:
name: Upload ['${{ matrix.os }}', python='${{ matrix.python }}']
Expand Down
15 changes: 14 additions & 1 deletion doc/reference/dtypes_table.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,35 @@ Table below shows a list of all supported data types (dtypes) and constants of t
- Constants
* -
- :obj:`bool <numpy.bool_>`
- :obj:`int8 <numpy.int8>`
- :obj:`int16 <numpy.int16>`
- :obj:`int32 <numpy.int32>`
- :obj:`int64 <numpy.int64>`
- :obj:`uint8 <numpy.uint8>`
- :obj:`uint16 <numpy.uint16>`
- :obj:`uint32 <numpy.uint32>`
- :obj:`uint64 <numpy.uint64>`
- :obj:`float32 <numpy.float32>`
- :obj:`float64 <numpy.float64>`
- :obj:`complex64 <numpy.complex64>`
- :obj:`complex128 <numpy.complex128>`
-
- :obj:`bool_ <numpy.bool_>`
- :obj:`byte <numpy.byte>`
- :obj:`cdouble <numpy.cdouble>`
- :obj:`csingle <numpy.csingle>`
- :obj:`double <numpy.double>`
- :obj:`float16 <numpy.float16>`
- :obj:`int <numpy.int>`
- :obj:`int_ <numpy.int_>`
- :obj:`intc <numpy.intc>`
- :obj:`intp <numpy.intp>`
- :obj:`longlong <numpy.longlong>`
- :obj:`single <numpy.single>`
- :obj:`ubyte <numpy.ubyte>`
- :obj:`uintc <numpy.uintc>`
- :obj:`uintp <numpy.uintp>`
- :obj:`ushort <numpy.ushort>`
- :obj:`ulonglong <numpy.ulonglong>`
-
- :obj:`e <numpy.e>`
- :obj:`euler_gamma <numpy.euler_gamma>`
Expand Down
32 changes: 30 additions & 2 deletions dpnp/dpnp_iface_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
__all__ = [
"bool",
"bool_",
"byte",
"cdouble",
"complex128",
"complex64",
Expand All @@ -57,21 +58,34 @@
"iinfo",
"inexact",
"inf",
"int",
"int_",
"int8",
"int16",
"int32",
"int64",
"integer",
"intc",
"intp",
"issubdtype",
"is_type_supported",
"longlong",
"nan",
"newaxis",
"number",
"pi",
"short",
"signedinteger",
"single",
"ubyte",
"uint8",
"uint16",
"uint32",
"uint64",
"uintc",
"uintp",
"unsignedinteger",
"ushort",
"ulonglong",
]


Expand All @@ -81,6 +95,7 @@
# =============================================================================
bool = numpy.bool_
bool_ = numpy.bool_
byte = numpy.byte
cdouble = numpy.cdouble
complex128 = numpy.complex128
complex64 = numpy.complex64
Expand All @@ -93,16 +108,29 @@
float64 = numpy.float64
floating = numpy.floating
inexact = numpy.inexact
int = numpy.int_
int_ = numpy.int_
int8 = numpy.int8
int16 = numpy.int16
int32 = numpy.int32
int64 = numpy.int64
integer = numpy.integer
intc = numpy.intc
intp = numpy.intp
longlong = numpy.longlong
number = numpy.number
short = numpy.short
signedinteger = numpy.signedinteger
single = numpy.single
ubyte = numpy.ubyte
uint8 = numpy.uint8
uint16 = numpy.uint16
uint32 = numpy.uint32
uint64 = numpy.uint64
uintc = numpy.uintc
uintp = numpy.uintp
unsignedinteger = numpy.unsignedinteger
ushort = numpy.ushort
ulonglong = numpy.ulonglong


# =============================================================================
Expand Down
6 changes: 6 additions & 0 deletions dpnp/tests/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os

all_int_types = int(os.getenv("DPNP_TEST_ALL_INT_TYPES", 0))
float16_types = int(os.getenv("DPNP_TEST_FLOAT_16", 0))
complex_types = int(os.getenv("DPNP_TEST_COMPLEX_TYPES", 0))
bool_types = int(os.getenv("DPNP_TEST_BOOL_TYPES", 0))
Loading

0 comments on commit a098910

Please sign in to comment.