Skip to content

Commit 08e1b26

Browse files
author
Vahid Tavanashad
committed
Merge branch 'master' into update-fft-test
2 parents c61f25b + 76f4360 commit 08e1b26

31 files changed

+398
-267
lines changed

.github/workflows/check-mkl-interfaces.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848

4949
- name: Merge conda env files
5050
run: |
51-
conda-merge ${{ env.build-with-oneapi-env }} ${{ env.dpctl-pkg-env }} ${{ env.oneapi-pkgs-env }} > ${{ env.environment-file }}
51+
conda-merge ${{ env.dpctl-pkg-env }} ${{ env.oneapi-pkgs-env }} ${{ env.build-with-oneapi-env }} > ${{ env.environment-file }}
5252
cat ${{ env.environment-file }}
5353
5454
- name: Upload artifact

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ jobs:
9393
continue-on-error: true
9494
run: conda build --no-test --python ${{ matrix.python }} --numpy 2.0 ${{ env.channels-list }} conda-recipe
9595
env:
96-
MAX_BUILD_CMPL_MKL_VERSION: '2025.1a0'
96+
MAX_BUILD_CMPL_MKL_VERSION: '2025.2a0'
9797

9898
- name: ReBuild conda package
9999
if: steps.build_conda_pkg.outcome == 'failure'
100100
run: conda build --no-test --python ${{ matrix.python }} --numpy 2.0 ${{ env.channels-list }} conda-recipe
101101
env:
102-
MAX_BUILD_CMPL_MKL_VERSION: '2025.1a0'
102+
MAX_BUILD_CMPL_MKL_VERSION: '2025.2a0'
103103

104104
- name: Upload artifact
105105
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2

.github/workflows/openssf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ jobs:
6868

6969
# Upload the results to GitHub's code scanning dashboard.
7070
- name: "Upload to code-scanning"
71-
uses: github/codeql-action/upload-sarif@5f8171a638ada777af81d42b55959a643bb29017 # v3.28.12
71+
uses: github/codeql-action/upload-sarif@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
7272
with:
7373
sarif_file: results.sarif

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3030

3131
- name: Set up python
32-
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
32+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
3333
with:
3434
python-version: '3.13'
3535

.pre-commit-config.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/PyCQA/bandit
5-
rev: '1.7.9'
5+
rev: '1.8.3'
66
hooks:
77
- id: bandit
88
pass_filenames: false
99
args: ["-r", "dpnp", "-lll"]
1010
- repo: https://github.com/pre-commit/pre-commit-hooks
11-
rev: v4.6.0
11+
rev: v5.0.0
1212
hooks:
1313
- id: check-ast
1414
- id: check-builtin-literals
@@ -44,17 +44,18 @@ repos:
4444
- id: rst-inline-touching-normal
4545
- id: text-unicode-replacement-char
4646
- repo: https://github.com/codespell-project/codespell
47-
rev: v2.3.0
47+
rev: v2.4.1
4848
hooks:
4949
- id: codespell
50+
args: ["-L", "abd"] # ignore "abd" used in einsum tests
5051
additional_dependencies:
5152
- tomli
5253
- repo: https://github.com/psf/black
53-
rev: 24.4.2
54+
rev: 25.1.0
5455
hooks:
5556
- id: black
5657
- repo: https://github.com/pycqa/isort
57-
rev: 5.13.2
58+
rev: 6.0.1
5859
hooks:
5960
- id: isort
6061
name: isort (python)
@@ -65,20 +66,20 @@ repos:
6566
name: isort (pyi)
6667
types: [pyi]
6768
- repo: https://github.com/pycqa/flake8
68-
rev: 7.1.0
69+
rev: 7.1.2
6970
hooks:
7071
- id: flake8
7172
args: ["--config=.flake8"]
7273
additional_dependencies:
7374
- flake8-docstrings==1.7.0
74-
- flake8-bugbear==24.4.26
75+
- flake8-bugbear==24.12.12
7576
- repo: https://github.com/pocc/pre-commit-hooks
7677
rev: v1.3.5
7778
hooks:
7879
- id: clang-format
7980
args: ["-i"]
8081
- repo: https://github.com/gitleaks/gitleaks
81-
rev: v8.18.4
82+
rev: v8.24.0
8283
hooks:
8384
- id: gitleaks
8485
- repo: https://github.com/jumanjihouse/pre-commit-hooks
@@ -102,3 +103,8 @@ repos:
102103
"--disable=unused-wildcard-import"
103104
]
104105
files: '^dpnp/(dpnp_iface.*|fft|linalg)'
106+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
107+
rev: v2.14.0
108+
hooks:
109+
- id: pretty-format-toml
110+
args: [--autofix]

CHANGELOG.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Changed
1717

18-
* Extended `dpnp.fft.fftfreq` and `dpnp.fft.rfftfreq` functions to support `dtype` keyword per Python Array API spec 2024.12 [#2384](https://github.com/IntelPython/dpnp/pull/2384)
18+
* Improved performance of `dpnp.nansum`, `dpnp.nanprod`, `dpnp.nancumsum`, and `dpnp.nancumprod` by reusing `dpnp.nan_to_num` function in implementation of the functions [#2339](https://github.com/IntelPython/dpnp/pull/2339)
1919
* Allowed input array of `uint64` dtype in `dpnp.bincount` [#2361](https://github.com/IntelPython/dpnp/pull/2361)
2020
* The vector norms `ord={None, 1, 2, inf}` and the matrix norms `ord={None, 1, 2, inf, "fro", "nuc"}` now consistently return zero for empty arrays, which are arrays with at least one axis of size zero. This change affects `dpnp.linalg.norm`, `dpnp.linalg.vector_norm`, and `dpnp.linalg.matrix_norm`. Previously, dpnp would either raise errors or return zero depending on the parameters provided [#2371](https://github.com/IntelPython/dpnp/pull/2371)
21-
* Improved performance of `dpnp.nansum`, `dpnp.nanprod`, `dpnp.nancumsum`, and `dpnp.nancumprod` by reusing `dpnp.nan_to_num` function in implementation of the functions [#2339](https://github.com/IntelPython/dpnp/pull/2339)
21+
* Extended `dpnp.fft.fftfreq` and `dpnp.fft.rfftfreq` functions to support `dtype` keyword per Python Array API spec 2024.12 [#2384](https://github.com/IntelPython/dpnp/pull/2384)
22+
* Updated `dpnp.fix` to return output with the same data-type of input [#2392](https://github.com/IntelPython/dpnp/pull/2392)
2223

2324
### Fixed
2425

2526
* Resolved an issue with an incorrect result returned due to missing dependency from the strided kernel on a copy event in `dpnp.erf` [#2378](https://github.com/IntelPython/dpnp/pull/2378)
27+
* Updated `conda create` commands build and install instructions of `Quick start guide` to avoid a compilation error [#2395](https://github.com/IntelPython/dpnp/pull/2395)
2628

2729

2830
## [0.17.0] - 02/26/2025

doc/quick_start_guide.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,18 @@ On Linux:
8888

8989
.. code-block:: bash
9090
91-
conda create -n build-env dpctl cython dpcpp_linux-64 mkl-devel-dpcpp tbb-devel onedpl-devel cmake scikit-build ninja pytest -c https://software.repos.intel.com/python/conda/ -c conda-forge
91+
conda create -n build-env dpctl cython dpcpp_linux-64 mkl-devel-dpcpp tbb-devel \
92+
onedpl-devel cmake scikit-build ninja pytest intel-gpu-ocl-icd-system \
93+
-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge
9294
conda activate build-env
9395
9496
On Windows:
9597

9698
.. code-block:: bash
9799
98-
conda create -n build-env dpctl cython dpcpp_win-64 mkl-devel-dpcpp tbb-devel onedpl-devel cmake scikit-build ninja pytest -c https://software.repos.intel.com/python/conda/ -c conda-forge
100+
conda create -n build-env dpctl cython dpcpp_win-64 mkl-devel-dpcpp tbb-devel \
101+
onedpl-devel cmake scikit-build ninja pytest intel-gpu-ocl-icd-system \
102+
-c dppy/label/dev -c https://software.repos.intel.com/python/conda/ -c conda-forge
99103
conda activate build-env
100104
101105
To build and install the package on Linux OS, run:

dpnp/dpnp_algo/dpnp_elementwise_common.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"DPNPI0",
4242
"DPNPAngle",
4343
"DPNPBinaryFunc",
44+
"DPNPFix",
4445
"DPNPImag",
4546
"DPNPReal",
4647
"DPNPRound",
@@ -511,6 +512,48 @@ def __call__(self, x, deg=False, out=None, order="K"):
511512
return res
512513

513514

515+
class DPNPFix(DPNPUnaryFunc):
516+
"""Class that implements dpnp.fix unary element-wise functions."""
517+
518+
def __init__(
519+
self,
520+
name,
521+
result_type_resolver_fn,
522+
unary_dp_impl_fn,
523+
docs,
524+
):
525+
super().__init__(
526+
name,
527+
result_type_resolver_fn,
528+
unary_dp_impl_fn,
529+
docs,
530+
)
531+
532+
def __call__(self, x, out=None, order="K"):
533+
if not dpnp.is_supported_array_type(x):
534+
pass # pass to raise error in main implementation
535+
elif dpnp.issubdtype(x.dtype, dpnp.inexact):
536+
pass # for inexact types, pass to calculate in the backend
537+
elif out is not None and not dpnp.is_supported_array_type(out):
538+
pass # pass to raise error in main implementation
539+
elif out is not None and out.dtype != x.dtype:
540+
# passing will raise an error but with incorrect needed dtype
541+
raise ValueError(
542+
f"Output array of type {x.dtype} is needed, got {out.dtype}"
543+
)
544+
else:
545+
# for exact types, return the input
546+
if out is None:
547+
return dpnp.copy(x, order=order)
548+
549+
if isinstance(out, dpt.usm_ndarray):
550+
out = dpnp_array._create_from_usm_ndarray(out)
551+
out[...] = x
552+
return out
553+
554+
return super().__call__(x, out=out, order=order)
555+
556+
514557
class DPNPI0(DPNPUnaryFunc):
515558
"""Class that implements dpnp.i0 unary element-wise functions."""
516559

dpnp/dpnp_iface_linearalgebra.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def einsum(
418418
>>> a = np.ones(64000).reshape(20, 40, 80)
419419
420420
Basic `einsum`: 119 ms ± 26 ms per loop (evaluated on 12th
421-
Gen Intel\u00AE Core\u2122 i7 processor)
421+
Gen Intel\u00ae Core\u2122 i7 processor)
422422
423423
>>> %timeit np.einsum("ijk,ilm,njm,nlk,abc->",a, a, a, a, a)
424424

dpnp/dpnp_iface_mathematical.py

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
DPNPI0,
6464
DPNPAngle,
6565
DPNPBinaryFunc,
66+
DPNPFix,
6667
DPNPImag,
6768
DPNPReal,
6869
DPNPRound,
@@ -1728,14 +1729,14 @@ def ediff1d(ary, to_end=None, to_begin=None):
17281729
Round to nearest integer towards zero.
17291730
17301731
Round an array of floats element-wise to nearest integer towards zero.
1731-
The rounded values are returned as floats.
1732+
The rounded values have the same data-type as the input.
17321733
17331734
For full documentation refer to :obj:`numpy.fix`.
17341735
17351736
Parameters
17361737
----------
17371738
x : {dpnp.ndarray, usm_ndarray}
1738-
An array of floats to be rounded.
1739+
Input array, expected to have a real-valued data type.
17391740
out : {None, dpnp.ndarray, usm_ndarray}, optional
17401741
Output array to populate.
17411742
Array must have the correct shape and the expected data type.
@@ -1749,19 +1750,12 @@ def ediff1d(ary, to_end=None, to_begin=None):
17491750
Returns
17501751
-------
17511752
out : dpnp.ndarray
1752-
An array with the rounded values and with the same dimensions as the input.
1753-
The returned array will have the default floating point data type for the
1754-
device where `a` is allocated.
1755-
If `out` is ``None`` then a float array is returned with the rounded values.
1753+
An array with the same dimensions and data-type as the input.
1754+
If `out` is ``None`` then a new array is returned
1755+
with the rounded values.
17561756
Otherwise the result is stored there and the return value `out` is
17571757
a reference to that array.
17581758
1759-
Limitations
1760-
-----------
1761-
Parameters `where` and `subok` are supported with their default values.
1762-
Keyword argument `kwargs` is currently unsupported.
1763-
Otherwise ``NotImplementedError`` exception will be raised.
1764-
17651759
See Also
17661760
--------
17671761
:obj:`dpnp.round` : Round to given number of decimals.
@@ -1782,7 +1776,7 @@ def ediff1d(ary, to_end=None, to_begin=None):
17821776
array([ 2., 2., -2., -2.])
17831777
"""
17841778

1785-
fix = DPNPUnaryFunc(
1779+
fix = DPNPFix(
17861780
"fix",
17871781
ufi._fix_result_type,
17881782
ufi._fix,
@@ -1934,8 +1928,10 @@ def ediff1d(ary, to_end=None, to_begin=None):
19341928
19351929
Notes
19361930
-----
1937-
Some spreadsheet programs calculate the "floor-towards-zero", in other words floor(-2.5) == -2.
1938-
DPNP instead uses the definition of floor where floor(-2.5) == -3.
1931+
Some spreadsheet programs calculate the "floor-towards-zero", where
1932+
``floor(-2.5) == -2``. DPNP instead uses the definition of :obj:`dpnp.floor`
1933+
where ``floor(-2.5) == -3``. The "floor-towards-zero" function is called
1934+
:obj:`dpnp.fix` in DPNP.
19391935
19401936
Examples
19411937
--------

0 commit comments

Comments
 (0)