Skip to content

Commit 71bf3d6

Browse files
authored
Merge branch 'master' into dependabot/github_actions/github-actions-6be86f213b
2 parents 275788f + 4252420 commit 71bf3d6

6 files changed

Lines changed: 56 additions & 32 deletions

File tree

‎.github/workflows/build-with-clang.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ jobs:
3333

3434
- name: Add Intel repository
3535
run: |
36-
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
37-
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
38-
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
39-
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
36+
wget -qO- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB \
37+
| gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
38+
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" \
39+
| sudo tee /etc/apt/sources.list.d/oneAPI.list
4040
sudo apt-get update
4141
4242
- name: Install Intel oneAPI

‎.github/workflows/conda-package-cf.yml‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ jobs:
5454
persist-credentials: false
5555
fetch-depth: 0
5656

57-
- name: Set pkgs_dirs
58-
run: |
59-
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
60-
6157
- name: Cache conda packages
6258
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
6359
env:
@@ -70,8 +66,11 @@ jobs:
7066
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_tag || matrix.python }}-
7167
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
7268
73-
- name: Add conda to system path
74-
run: echo "$CONDA"/bin >> "$GITHUB_PATH"
69+
- uses: conda-incubator/setup-miniconda@be893c923ea9cf1cf7cd510fbdde27c7e18cbdcb # v4.1.0
70+
with:
71+
miniforge-version: latest
72+
activate-environment: ""
73+
pkgs-dirs: ~/.conda/pkgs
7574

7675
- name: Install conda-build
7776
run: conda install conda-build
@@ -92,7 +91,7 @@ jobs:
9291
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
9392
with:
9493
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python_tag || matrix.python }}
95-
path: /usr/share/miniconda/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda
94+
path: ${{ env.CONDA }}/conda-bld/linux-64/${{ env.PACKAGE_NAME }}-*.conda
9695

9796
test_linux:
9897
needs: build_linux
@@ -133,8 +132,11 @@ jobs:
133132
with:
134133
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python_tag || matrix.python }}
135134

136-
- name: Add conda to system path
137-
run: echo "$CONDA"/bin >> "$GITHUB_PATH"
135+
- uses: conda-incubator/setup-miniconda@be893c923ea9cf1cf7cd510fbdde27c7e18cbdcb # v4.1.0
136+
with:
137+
miniforge-version: latest
138+
activate-environment: ""
139+
pkgs-dirs: ~/.conda/pkgs
138140

139141
- name: Install conda-build
140142
run: conda install conda-build
@@ -155,10 +157,6 @@ jobs:
155157
- name: Display lockfile
156158
run: cat lockfile
157159

158-
- name: Set pkgs_dirs
159-
run: |
160-
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
161-
162160
- name: Cache conda packages
163161
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
164162
env:

‎.github/workflows/conda-package.yml‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ jobs:
5454
persist-credentials: false
5555
fetch-depth: 0
5656

57-
- name: Set pkgs_dirs
58-
run: |
59-
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
60-
6157
- name: Cache conda packages
6258
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
6359
env:
@@ -70,12 +66,15 @@ jobs:
7066
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-python-${{ matrix.python_tag || matrix.python }}-
7167
${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-
7268
73-
- name: Add conda to system path
74-
run: echo "$CONDA"/bin >> "$GITHUB_PATH"
69+
- uses: conda-incubator/setup-miniconda@be893c923ea9cf1cf7cd510fbdde27c7e18cbdcb # v4.1.0
70+
with:
71+
miniforge-version: latest
72+
activate-environment: ""
73+
pkgs-dirs: ~/.conda/pkgs
7574

7675
- name: Store conda paths as envs
7776
run: |
78-
echo "CONDA_BLD=/usr/share/miniconda/conda-bld/linux-64/" >> "$GITHUB_ENV"
77+
echo "CONDA_BLD=$CONDA/conda-bld/linux-64/" >> "$GITHUB_ENV"
7978
echo "WHEELS_OUTPUT_FOLDER=$GITHUB_WORKSPACE/" >> "$GITHUB_ENV"
8079
8180
- name: Update conda
@@ -156,8 +155,11 @@ jobs:
156155
with:
157156
name: ${{ env.PACKAGE_NAME }} ${{ runner.os }} Python ${{ matrix.python_tag || matrix.python }}
158157

159-
- name: Add conda to system path
160-
run: echo "$CONDA"/bin >> "$GITHUB_PATH"
158+
- uses: conda-incubator/setup-miniconda@be893c923ea9cf1cf7cd510fbdde27c7e18cbdcb # v4.1.0
159+
with:
160+
miniforge-version: latest
161+
activate-environment: ""
162+
pkgs-dirs: ~/.conda/pkgs
161163

162164
- name: Update conda
163165
run: |
@@ -196,10 +198,6 @@ jobs:
196198
- name: Display lockfile
197199
run: cat lockfile
198200

199-
- name: Set pkgs_dirs
200-
run: |
201-
echo "pkgs_dirs: [~/.conda/pkgs]" >> ~/.condarc
202-
203201
- name: Cache conda packages
204202
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
205203
env:

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010

1111
### Changed
12+
* `irfft` with `out=` now writes directly into `out` when the cast or zero-padded copy of a non-contiguous input has the same memory order as `out`, avoiding a temporary array and an extra copy [gh-396](https://github.com/IntelPython/mkl_fft/pull/396)
1213

1314
### Fixed
1415

‎mkl_fft/_pydfti.pyx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,10 @@ def _c2r_fft1d_impl(
750750
# strides cannot be compared directly.
751751
# TODO: currently instead of this condition, we check both input
752752
# and output to be c_contig or f_contig, relax this condition
753-
c_contig = x.flags.c_contiguous and out.flags.c_contiguous
754-
f_contig = x.flags.f_contiguous and out.flags.f_contiguous
753+
# Check x_arr, which may be a cast copy of x with a different
754+
# layout (e.g. when x is non-contiguous and gets cast to complex).
755+
c_contig = x_arr.flags.c_contiguous and out.flags.c_contiguous
756+
f_contig = x_arr.flags.f_contiguous and out.flags.f_contiguous
755757
if c_contig or f_contig:
756758
f_arr = <cnp.ndarray> out
757759
else:

‎mkl_fft/tests/test_fft1d.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,31 @@ def test_irfft_out_strided(axis):
488488
assert np.all(base == -1.0)
489489

490490

491+
@pytest.mark.parametrize("order", ["C", "F"])
492+
@pytest.mark.parametrize("axis", [0, 1, 2])
493+
@pytest.mark.parametrize("dt", ["i8", "f4", "f8", "c16"])
494+
def test_irfft_out_strided_input_copied(dt, axis, order):
495+
# x is strided, but it is cast (i8, f4, f8) or padded (c16) into a
496+
# contiguous copy, whose layout decides if MKL can write into out directly
497+
x = rnd.randint(-50, 50, size=(20, 33, 54)).astype(dt)
498+
x = np.asarray(x, order=order)[::2, ::3, ::4]
499+
n = None
500+
if dt == "c16":
501+
# n // 2 + 1 > x.shape[axis] forces a zero-padded copy
502+
n = 2 * x.shape[axis] + 4
503+
out_shape = list(x.shape)
504+
out_shape[axis] = 2 * (x.shape[axis] - 1) if n is None else n
505+
out_dtype = np.float32 if dt == "f4" else np.float64
506+
# sentinel: catches out being returned untouched
507+
out = np.full(out_shape, -1.0, dtype=out_dtype, order=order)
508+
result = mkl_fft.irfft(x, n=n, axis=axis, out=out)
509+
expected = np.fft.irfft(x.astype(np.complex128), n=n, axis=axis)
510+
511+
assert result is out
512+
tol = 1e-4 if dt == "f4" else 1e-10
513+
assert_allclose(result, expected, rtol=tol, atol=tol)
514+
515+
491516
@requires_numpy_2
492517
@pytest.mark.parametrize("dt", ["i4", "f4", "f8", "c8", "c16"])
493518
def test_irfft_dtype(dt):

0 commit comments

Comments
 (0)