Skip to content

Commit fb12707

Browse files
authored
Merge branch 'master' into revisit_overwrite_x
2 parents c151d6a + 93ef7f2 commit fb12707

File tree

9 files changed

+66
-47
lines changed

9 files changed

+66
-47
lines changed

.github/workflows/conda-package.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555

5656
- name: Build conda package
5757
run: |
58-
CHANNELS="-c conda-forge -c https://software.repos.intel.com/python/conda --override-channels"
58+
CHANNELS="-c https://software.repos.intel.com/python/conda -c conda-forge --override-channels"
5959
VERSIONS="--python ${{ matrix.python }}"
6060
TEST="--no-test"
6161
@@ -101,8 +101,17 @@ jobs:
101101
mkdir -p $GITHUB_WORKSPACE/channel/linux-64
102102
mv ${PACKAGE_NAME}-*.conda $GITHUB_WORKSPACE/channel/linux-64
103103
conda index $GITHUB_WORKSPACE/channel
104-
# Test channel
105-
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels
104+
105+
- name: Test conda channel
106+
run: |
107+
conda search $PACKAGE_NAME -c $GITHUB_WORKSPACE/channel --override-channels --info --json > $GITHUB_WORKSPACE/ver.json
108+
cat $GITHUB_WORKSPACE/ver.json
109+
110+
- name: Get package version
111+
run: |
112+
export PACKAGE_VERSION=$(python -c "${{ env.VER_SCRIPT1 }} ${{ env.VER_SCRIPT2 }}")
113+
echo PACKAGE_VERSION=${PACKAGE_VERSION}
114+
echo "PACKAGE_VERSION=$PACKAGE_VERSION" >> $GITHUB_ENV
106115
107116
- name: Collect dependencies
108117
run: |
@@ -131,8 +140,7 @@ jobs:
131140
- name: Install mkl_fft
132141
run: |
133142
CHANNELS="-c $GITHUB_WORKSPACE/channel ${{ env.CHANNELS }}"
134-
conda create -n ${{ env.TEST_ENV_NAME }} python=${{ matrix.python }} "scipy>=1.10" $CHANNELS
135-
conda install -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME pytest $CHANNELS
143+
conda create -n ${{ env.TEST_ENV_NAME }} $PACKAGE_NAME=${{ env.PACKAGE_VERSION }} python=${{ matrix.python }} pytest "scipy>=1.10" $CHANNELS
136144
# Test installed packages
137145
conda list -n ${{ env.TEST_ENV_NAME }}
138146

.github/workflows/openssf-scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
persist-credentials: false
4040

4141
- name: "Run analysis"
42-
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
42+
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
4343
with:
4444
results_file: results.sarif
4545
results_format: sarif

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [dev] (MM/DD/YY)
7+
## [2.0.0] (05/DD/2025)
88

99
### Added
1010
* Added Hermitian FFT functions to SciPy interface `mkl_fft.interfaces.scipy_fft`: `hfft`, `ihfft`, `hfftn`, `ihfftn`, `hfft2`, and `ihfft2` [gh-161](https://github.com/IntelPython/mkl_fft/pull/161)

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@
44
[![Conda package with conda-forge channel only](https://github.com/IntelPython/mkl_fft/actions/workflows/conda-package-cf.yml/badge.svg)](https://github.com/IntelPython/mkl_fft/actions/workflows/conda-package-cf.yml)
55
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/IntelPython/mkl_fft/badge)](https://securityscorecards.dev/viewer/?uri=github.com/IntelPython/mkl_fft)
66

7+
# Introduction
78
`mkl_fft` started as a part of Intel® Distribution for Python* optimizations to NumPy, and is now being released
8-
as a stand-alone package. It can be installed into conda environment from Intel's channel using:
9+
as a stand-alone package. It offers a thin layered interface for the Intel® oneAPI Math Kernel Library (OneMKL) FFT functionality that allows efficient access to native FFT optimizations from a range of NumPy and SciPy functions. As a result, its performance is close to the performance of native C/Intel® OneMKL. The optimizations are provided for real and complex data types in both single and double precisions for in-place and out-of-place modes of operation. For analyzing the performance use [FFT benchmarks](https://github.com/intelpython/fft_benchmark).
10+
11+
Thanks to Intel® OneMKL’s flexibility in its supports for arbitrarily strided input and output arrays both one-dimensional and multi-dimensional Fast Fourier Transforms along distinct axes can be performed directly, without the need to copy the input into a contiguous array first. Furthermore, input strides can be arbitrary, including negative or zero, as long as strides remain an integer multiple of array’s item size, otherwise a copy will be made.
12+
13+
More details can be found in ["Accelerating Scientific Python with Intel Optimizations"](https://proceedings.scipy.org/articles/shinma-7f4c6e7-00f) from Proceedings of the 16th Python in Science Conference (SciPy 2017).
14+
15+
---
16+
# Installation
17+
`mkl_fft` can be installed into conda environment from Intel's channel using:
918

1019
```
1120
conda install -c https://software.repos.intel.com/python/conda mkl_fft
@@ -34,22 +43,12 @@ If command above installs NumPy package from the PyPI, please use following comm
3443
Where `<numpy_version>` should be the latest version from https://software.repos.intel.com/python/conda/
3544

3645
---
46+
# How to use?
47+
## `mkl_fft.interfaces` module
48+
The recommended way to use `mkl_fft` package is through `mkl_fft.interfaces` module. These interfaces act as drop-in replacements for equivalent functions in NumPy and SciPy. Learn more about these interfaces [here](https://github.com/IntelPython/mkl_fft/blob/master/mkl_fft/interfaces/README.md).
3749

38-
Since MKL FFT supports performing discrete Fourier transforms over non-contiguously laid out arrays, OneMKL can be directly
39-
used on any well-behaved floating point array with no internal overlaps for both in-place and not in-place transforms of
40-
arrays in single and double floating point precision.
41-
42-
This eliminates the need to copy input array contiguously into an intermediate buffer.
43-
44-
`mkl_fft` directly supports N-dimensional Fourier transforms.
45-
46-
More details can be found in [SciPy 2017 conference proceedings](https://github.com/scipy-conference/scipy_proceedings/tree/2017/papers/oleksandr_pavlyk).
47-
48-
---
49-
50-
The `mkl_fft` package offers interfaces that act as drop-in replacements for equivalent functions in NumPy and SciPy. Learn more about these interfaces [here](https://github.com/IntelPython/mkl_fft/blob/master/mkl_fft/interfaces/README.md).
51-
52-
While using these interfaces is the easiest way to leverage `mk_fft`, one can also use `mkl_fft` directly with the following FFT functions:
50+
## `mkl_fft` package
51+
While using the interfaces module is the recommended way to leverage `mk_fft`, one can also use `mkl_fft` directly with the following FFT functions:
5352

5453
### complex-to-complex (c2c) transforms:
5554

@@ -84,6 +83,7 @@ numpy.allclose(mkl_res, np_res)
8483
```
8584

8685
---
86+
# Building from source
8787

8888
To build `mkl_fft` from sources on Linux with Intel® OneMKL:
8989
- create a virtual environment: `python3 -m venv fft_env`

conda-recipe-cf/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "1.3.14" %}
1+
{% set version = "2.0.0" %}
22
{% set buildnumber = 0 %}
33

44
package:

conda-recipe/meta.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "1.3.14" %}
1+
{% set version = "2.0.0" %}
22
{% set buildnumber = 0 %}
33

44
package:
@@ -20,6 +20,7 @@ requirements:
2020
- python
2121
- setuptools >=77
2222
- mkl-devel
23+
- mkl-devel 2024.2.* # [py==39 or py==310]
2324
- cython
2425
- numpy-base
2526
run:

mkl_fft/_pydfti.pyx

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ cdef cnp.ndarray _pad_array(
203203
b_shape[axis] = n
204204

205205
# allocating temporary buffer
206-
x_arr_is_fortran = cnp.PyArray_CHKFLAGS(x_arr, cnp.NPY_F_CONTIGUOUS)
206+
x_arr_is_fortran = cnp.PyArray_CHKFLAGS(x_arr, cnp.NPY_ARRAY_F_CONTIGUOUS)
207207
b_arr = <cnp.ndarray> cnp.PyArray_EMPTY(
208208
b_ndim, b_shape, <cnp.NPY_TYPES> b_type, x_arr_is_fortran
209209
) # 0 for C-contiguous
@@ -239,9 +239,12 @@ cdef cnp.ndarray _process_arguments(
239239

240240
# convert x to ndarray, ensure that strides are multiples of itemsize
241241
x_arr = PyArray_CheckFromAny(
242-
x, NULL, 0, 0,
243-
cnp.NPY_ELEMENTSTRIDES | cnp.NPY_ENSUREARRAY | cnp.NPY_NOTSWAPPED,
244-
NULL)
242+
x, NULL, 0, 0,
243+
cnp.NPY_ARRAY_ELEMENTSTRIDES |
244+
cnp.NPY_ARRAY_ENSUREARRAY |
245+
cnp.NPY_ARRAY_NOTSWAPPED,
246+
NULL
247+
)
245248

246249
if (<void *> x_arr) is NULL:
247250
raise ValueError("An input argument x is not an array-like object")
@@ -309,7 +312,7 @@ cdef cnp.ndarray _allocate_result(
309312
f_shape[axis_] = n_
310313

311314
# allocating output buffer
312-
x_arr_is_fortran = cnp.PyArray_CHKFLAGS(x_arr, cnp.NPY_F_CONTIGUOUS)
315+
x_arr_is_fortran = cnp.PyArray_CHKFLAGS(x_arr, cnp.NPY_ARRAY_F_CONTIGUOUS)
313316
f_arr = <cnp.ndarray> cnp.PyArray_EMPTY(
314317
f_ndim, f_shape, <cnp.NPY_TYPES> f_type, x_arr_is_fortran
315318
) # 0 for C-contiguous
@@ -402,7 +405,9 @@ def _c2c_fft1d_impl(x, n=None, axis=-1, direction=+1, double fsc=1.0, out=None):
402405
# so we cast to complex double and operate in place
403406
try:
404407
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
405-
x_arr, cnp.NPY_CDOUBLE, cnp.NPY_BEHAVED | cnp.NPY_ENSURECOPY)
408+
x_arr, cnp.NPY_CDOUBLE,
409+
cnp.NPY_ARRAY_BEHAVED | cnp.NPY_ARRAY_ENSURECOPY
410+
)
406411
except:
407412
raise ValueError(
408413
"First argument must be a complex "
@@ -582,9 +587,9 @@ def _r2c_fft1d_impl(
582587
else:
583588
# we must cast the input to doubles and allocate the output,
584589
try:
585-
requirement = cnp.NPY_BEHAVED | cnp.NPY_ENSURECOPY
590+
requirement = cnp.NPY_ARRAY_BEHAVED | cnp.NPY_ARRAY_ENSURECOPY
586591
if x_type is cnp.NPY_LONGDOUBLE:
587-
requirement = requirement | cnp.NPY_FORCECAST
592+
requirement = requirement | cnp.NPY_ARRAY_FORCECAST
588593
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
589594
x_arr, cnp.NPY_DOUBLE, requirement)
590595
x_type = cnp.PyArray_TYPE(x_arr)
@@ -684,11 +689,11 @@ def _c2r_fft1d_impl(
684689
# so we cast to complex double and operate in place
685690
if x_type is cnp.NPY_FLOAT:
686691
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
687-
x_arr, cnp.NPY_CFLOAT, cnp.NPY_BEHAVED
692+
x_arr, cnp.NPY_CFLOAT, cnp.NPY_ARRAY_BEHAVED
688693
)
689694
else:
690695
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
691-
x_arr, cnp.NPY_CDOUBLE, cnp.NPY_BEHAVED
696+
x_arr, cnp.NPY_CDOUBLE, cnp.NPY_ARRAY_BEHAVED
692697
)
693698
x_type = cnp.PyArray_TYPE(x_arr)
694699
in_place = 1
@@ -763,9 +768,12 @@ def _direct_fftnd(
763768

764769
# convert x to ndarray, ensure that strides are multiples of itemsize
765770
x_arr = PyArray_CheckFromAny(
766-
x, NULL, 0, 0,
767-
cnp.NPY_ELEMENTSTRIDES | cnp.NPY_ENSUREARRAY | cnp.NPY_NOTSWAPPED,
768-
NULL)
771+
x, NULL, 0, 0,
772+
cnp.NPY_ARRAY_ELEMENTSTRIDES |
773+
cnp.NPY_ARRAY_ENSUREARRAY |
774+
cnp.NPY_ARRAY_NOTSWAPPED,
775+
NULL
776+
)
769777

770778
if <void *> x_arr is NULL:
771779
raise ValueError("An input argument x is not an array-like object")
@@ -783,7 +791,9 @@ def _direct_fftnd(
783791
pass
784792
else:
785793
x_arr = <cnp.ndarray> cnp.PyArray_FROM_OTF(
786-
x_arr, cnp.NPY_CDOUBLE, cnp.NPY_BEHAVED | cnp.NPY_ENSURECOPY)
794+
x_arr, cnp.NPY_CDOUBLE,
795+
cnp.NPY_ARRAY_BEHAVED | cnp.NPY_ARRAY_ENSURECOPY
796+
)
787797
x_type = cnp.PyArray_TYPE(x_arr)
788798
assert x_type == cnp.NPY_CDOUBLE
789799
in_place = 1

mkl_fft/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.3.14"
1+
__version__ = "2.0.0"

mkl_fft/interfaces/numpy_fft.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2525
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626

27-
# Added for completing the namespaces
28-
from numpy.fft import fftfreq, fftshift, ifftshift, rfftfreq
29-
3027
# pylint: disable=no-name-in-module
3128
from ._numpy_fft import (
3229
fft,
@@ -60,8 +57,11 @@
6057
"irfftn",
6158
"hfft",
6259
"ihfft",
63-
"fftshift",
64-
"ifftshift",
65-
"fftfreq",
66-
"rfftfreq",
6760
]
61+
62+
# It is important to put the following import here to avoid circular imports
63+
# when patching numpy with mkl_fft
64+
# Added for completing the namespaces
65+
from numpy.fft import fftfreq, fftshift, ifftshift, rfftfreq
66+
67+
__all__ += ["fftshift", "ifftshift", "fftfreq", "rfftfreq"]

0 commit comments

Comments
 (0)