Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pypocketfft
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Reinecke
pypocketfft
Commits
e4576e41
Commit
e4576e41
authored
5 years ago
by
Peter Bell
Committed by
Martin Reinecke
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Export good_size using raw C-API
parent
8961a318
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
pypocketfft.cc
+25
-3
25 additions, 3 deletions
pypocketfft.cc
with
25 additions
and
3 deletions
pypocketfft.cc
+
25
−
3
View file @
e4576e41
...
...
@@ -372,10 +372,29 @@ py::array genuine_hartley(const py::array &in, const py::object &axes_,
out_
,
nthreads
))
}
size_t
good_size
(
size_t
n
,
bool
real
)
// Export good_size in raw C-API to reduce overhead (~4x faster)
PyObject
*
good_size
(
PyObject
*
self
,
PyObject
*
args
)
{
Py_ssize_t
n_
=
-
1
;
int
real
=
false
;
if
(
!
PyArg_ParseTuple
(
args
,
"n|p:good_size"
,
&
n_
,
&
real
))
return
nullptr
;
if
(
n_
<
0
)
{
PyErr_SetString
(
PyExc_ValueError
,
"Target length must be positive"
);
return
nullptr
;
}
if
((
n_
-
1
)
>
static_cast
<
Py_ssize_t
>
(
std
::
numeric_limits
<
size_t
>::
max
()
/
11
))
{
PyErr_Format
(
PyExc_ValueError
,
"Target length is too large to perform an FFT: %zi"
,
n_
);
return
nullptr
;
}
const
auto
n
=
static_cast
<
size_t
>
(
n_
);
using
namespace
pocketfft
::
detail
;
return
real
?
util
::
good_size_real
(
n
)
:
util
::
good_size_cmplx
(
n
);
return
PyLong_FromSize_t
(
real
?
util
::
good_size_real
(
n
)
:
util
::
good_size_cmplx
(
n
));
}
const
char
*
pypocketfft_DS
=
R"""(Fast Fourier and Hartley transforms.
...
...
@@ -702,5 +721,8 @@ PYBIND11_MODULE(pypocketfft, m)
"out"
_a
=
None
,
"nthreads"
_a
=
1
);
m
.
def
(
"dst"
,
dst
,
dst_DS
,
"a"
_a
,
"type"
_a
,
"axes"
_a
=
None
,
"inorm"
_a
=
0
,
"out"
_a
=
None
,
"nthreads"
_a
=
1
);
m
.
def
(
"good_size"
,
good_size
,
good_size_DS
,
"n"
_a
,
"real"
_a
=
false
);
static
PyMethodDef
good_size_meth
[]
=
{{
"good_size"
,
good_size
,
METH_VARARGS
,
good_size_DS
},
{
0
}};
PyModule_AddFunctions
(
m
.
ptr
(),
good_size_meth
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment