Skip to content

Commit e6ef92c

Browse files
committed
task: review
1 parent badf839 commit e6ef92c

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
* Multi-iterator constructors now return a status corresponding to allocation success or failure, and raise `MemoryError` instead of `ValueError` [gh-373](https://github.com/IntelPython/mkl_fft/pull/373)
1313
* `_direct_fftnd` now also checks the status returned by the backend instead of discarding it [gh-373](https://github.com/IntelPython/mkl_fft/pull/373)
1414
* Pinned Cython in the Coverity Scan workflow so generated code stays stable between scans, and added `coverity/README.md` documenting the known false-positive families and the scan review checklist [gh-374](https://github.com/IntelPython/mkl_fft/pull/374)
15+
* Reduced Python overhead in `norm="forward"`/`"ortho"` scaling by computing the scale factor without `numpy.prod` [gh-384](https://github.com/IntelPython/mkl_fft/pull/384)
1516

1617
### Fixed
1718
* Fixed `norm="forward"`/`"ortho"` scaling in `fftn`, `ifftn`, `rfftn`, `irfftn` and the `fft2` family when only a subset of axes is transformed: the scale used the full array shape instead of the transformed axes [gh-336](https://github.com/IntelPython/mkl_fft/issues/336), [gh-370](https://github.com/IntelPython/mkl_fft/pull/370)

‎mkl_fft/_fft_utils.py‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,9 @@ def _compute_fwd_scale(norm, n, shape):
7272
return 1.0
7373

7474
ss = n if n is not None else shape
75-
# `np.prod` dominates the Python-side cost of a small normalized transform,
76-
# so take cheaper routes for the two shapes the callers actually pass: a
77-
# scalar `n` (1-D) and a sequence (`_nd_fwd_scale`). It stays the fallback
78-
# because `numpy.fft` also accepts array-like `n` and `s` (e.g. a 0-d
79-
# `n=np.array(8)`, a 1-D `s=np.array([4, 4])`), which `math.prod` cannot
80-
# handle uniformly.
75+
# Avoid np.prod's array-creation overhead on the hot scalar (1-D) and
76+
# sequence (N-D) paths; np.prod stays as the fallback for array-like
77+
# `n`/`s` (e.g. np.array(8)) that math.prod can't handle.
8178
if isinstance(ss, (int, np.integer)):
8279
nn = ss
8380
elif isinstance(ss, (list, tuple)):

0 commit comments

Comments
 (0)