From 7a4c1610c8b11f701cee7f8206125c23ce7ff98a Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sat, 20 Sep 2025 02:48:05 +0800 Subject: [PATCH 1/3] _pocketfft_umath.cpp: fix types Fixes: https://github.com/numpy/numpy/issues/29758 Credits to @seberg --- numpy/fft/_pocketfft_umath.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/numpy/fft/_pocketfft_umath.cpp b/numpy/fft/_pocketfft_umath.cpp index ab8af5aa522e..dc4851ccdf8f 100644 --- a/numpy/fft/_pocketfft_umath.cpp +++ b/numpy/fft/_pocketfft_umath.cpp @@ -32,7 +32,7 @@ template static void wrap_legacy_cpp_ufunc(char **args, npy_intp const *dimensions, - ptrdiff_t const *steps, void *func) + npy_intp const *steps, void *func) { NPY_ALLOW_C_API_DEF try { @@ -86,14 +86,14 @@ copy_output(T buff[], char *out, npy_intp step_out, size_t n) */ template static void -fft_loop(char **args, npy_intp const *dimensions, ptrdiff_t const *steps, +fft_loop(char **args, npy_intp const *dimensions, npy_intp const *steps, void *func) { char *ip = args[0], *fp = args[1], *op = args[2]; size_t n_outer = (size_t)dimensions[0]; - ptrdiff_t si = steps[0], sf = steps[1], so = steps[2]; + npy_intp si = steps[0], sf = steps[1], so = steps[2]; size_t nin = (size_t)dimensions[1], nout = (size_t)dimensions[2]; - ptrdiff_t step_in = steps[3], step_out = steps[4]; + npy_intp step_in = steps[3], step_out = steps[4]; bool direction = *((bool *)func); /* pocketfft::FORWARD or BACKWARD */ assert (nout > 0); @@ -144,9 +144,9 @@ rfft_impl(char **args, npy_intp const *dimensions, npy_intp const *steps, { char *ip = args[0], *fp = args[1], *op = args[2]; size_t n_outer = (size_t)dimensions[0]; - ptrdiff_t si = steps[0], sf = steps[1], so = steps[2]; + npy_intp si = steps[0], sf = steps[1], so = steps[2]; size_t nin = (size_t)dimensions[1], nout = (size_t)dimensions[2]; - ptrdiff_t step_in = steps[3], step_out = steps[4]; + npy_intp step_in = steps[3], step_out = steps[4]; assert (nout > 0 && nout == npts / 2 + 1); From b624e054d5788531d760d2f0b5d6a84a093f4d88 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sat, 20 Sep 2025 03:00:30 +0800 Subject: [PATCH 2/3] _pocketfft_umath.cpp: fix unused variable warning --- numpy/fft/_pocketfft_umath.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/numpy/fft/_pocketfft_umath.cpp b/numpy/fft/_pocketfft_umath.cpp index dc4851ccdf8f..18a1a1cd763d 100644 --- a/numpy/fft/_pocketfft_umath.cpp +++ b/numpy/fft/_pocketfft_umath.cpp @@ -233,8 +233,9 @@ irfft_loop(char **args, npy_intp const *dimensions, npy_intp const *steps, void size_t nin = (size_t)dimensions[1], nout = (size_t)dimensions[2]; ptrdiff_t step_in = steps[3], step_out = steps[4]; +#ifndef POCKETFFT_NO_VECTORS size_t npts_in = nout / 2 + 1; - +#endif assert(nout > 0); #ifndef POCKETFFT_NO_VECTORS From 89d50f8aa7203c13fc7e563821ecac427738b740 Mon Sep 17 00:00:00 2001 From: Sebastian Berg Date: Mon, 22 Sep 2025 09:22:10 +0200 Subject: [PATCH 3/3] Move npts_in calculation into #ifndef --- numpy/fft/_pocketfft_umath.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/numpy/fft/_pocketfft_umath.cpp b/numpy/fft/_pocketfft_umath.cpp index 18a1a1cd763d..f616fe9b0bdc 100644 --- a/numpy/fft/_pocketfft_umath.cpp +++ b/numpy/fft/_pocketfft_umath.cpp @@ -233,15 +233,13 @@ irfft_loop(char **args, npy_intp const *dimensions, npy_intp const *steps, void size_t nin = (size_t)dimensions[1], nout = (size_t)dimensions[2]; ptrdiff_t step_in = steps[3], step_out = steps[4]; -#ifndef POCKETFFT_NO_VECTORS - size_t npts_in = nout / 2 + 1; -#endif assert(nout > 0); #ifndef POCKETFFT_NO_VECTORS /* * Call pocketfft directly if vectorization is possible. */ + size_t npts_in = nout / 2 + 1; constexpr auto vlen = pocketfft::detail::VLEN::val; if (vlen > 1 && n_outer >= vlen && nin >= npts_in && sf == 0) { std::vector axes = { 1 };