-
-
Notifications
You must be signed in to change notification settings - Fork 668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Refactor FFT classes for object factory registration #2864
ENH: Refactor FFT classes for object factory registration #2864
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this contribution. My main concern is duplication of repetitive code. That can probably be solved via a macro, unless there is a more elegant solution.
Modules/Filtering/FFT/include/itkComplexToComplex1DFFTImageFilter.h
Outdated
Show resolved
Hide resolved
Modules/Filtering/FFT/include/itkFFTWComplexToComplexFFTImageFilter.h
Outdated
Show resolved
Hide resolved
Modules/Filtering/FFT/wrapping/itkComplexToComplex1DFFTImageFilter.wrap
Outdated
Show resolved
Hide resolved
bce06d7
to
faeb39e
Compare
142133e
to
453a201
Compare
When this compiles, convert it back into a ready PR. If you want me to review before then, ping me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. A few comments about the FFTImageFilterTraits
.
After resolving several compile/test issues I'm still seeing a strange failure in Python tests. CDash shows that
I've traced this back to template <typename TInputImage, typename TKernelImage, typename TOutputImage, typename TInternalPrecision>
FFTConvolutionImageFilter<TInputImage, TKernelImage, TOutputImage, TInternalPrecision>::FFTConvolutionImageFilter()
{
m_SizeGreatestPrimeFactor = FFTFilterType::New()->GetSizeGreatestPrimeFactor();
} However, Factories should be registered in Python by default, especially given that Investigation notes:
Open to suggestions on how to proceed here. Would like to avoid adding dynamic Python factory registration expansions to this PR as it's already very large, but will reluctantly head that way if that is the required resolution. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can squash the changes so far?
Co-authored-by: Lee Newberg <lee.newberg@kitware.com>
bc8857b
to
a7d1fdf
Compare
In case it is not a red herring, ... in #2890 there is a short discussion that might explain why factories that are registered don't appear that way to other parts of the code. It includes
|
Thanks @Leengit , this sounds like the most likely cause right now. I'll have to look more into how the |
Some series templating here! 🕺 @tbirdso do these examples still work when built against this branch? |
Hi @thewtex , yes, the FFT examples still work when built against this branch on Windows. I'll also note that instantiating I'm working on building the examples in Linux, in the meantime I've submitted a small path for the inverse FFT example here: InsightSoftwareConsortium/ITKSphinxExamples#312 |
Verified that Linux FFT examples build. So far the problem seems limited to using object factories in consuming modules in Python on Linux, i.e. using FFT object factories in Convolution filters. The discussion in #2890 in regards to magic statics may be the root of the issue, though I'm not clear at the moment why this would be platform-dependent behavior. |
Current hypothesis: registering FFT factories with "magic statics" in #2890 dealing with magic statics was abandoned (at least for now) due to In an initial test registering As I see it there are two ways to proceed here:
I'm certainly open to other ideas here as well. Pinging @N-Dekker and @thewtex for discussion of object factories + magic statics. |
Marking as ready for review but intentionally leaving the last commit unsquashed for design discussion. |
Per discussion with @thewtex we will leave FFT registration as-is for now, but follow up with changes to synchronize |
For future reference, reading a few lines into documentation on C APIs for Python extension modules reveals a likely answer for why FFT factories registered with magic statics were visible across modules in Windows but not in Linux:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚒️ great progress!!
I created an issue to track the next step of object factory resolution in #2909
Takes the object factory structure introduced to
itk::Forward1DFFTImageFilter
in #2836 and extends it to all FFT classes.Relying on object factories for generating FFT classes will allow users to flexibly override FFT implementations so that their default backend is the one best for their own system. Developers can develop against base classes such as
itk::ComplexToComplexFFTImageFilter
,itk::HalfHermitianToRealInverseFFTImageFilter
, etc, without needing to know whether the FFT backend is Vnl, FFTW, or something else.Prior to these changes backend selection was performed with dispatch methods overriding base constructors, which locked in available backends to those included with ITK proper. Moving to the object factory framework will allow remote modules to inject accelerated backend defaults, such as in the case of https://github.com/InsightSoftwareConsortium/ITKVkFFTBackend.
Consuming projects must use
include(UseITK.cmake)
to properly initialize default object factory registrations. Discussion in #2836 concluded that ITK tests do not include this line and therefore do not register factories by default, hence filtering cxx tests relying on arbitrary FFT classes have been refactored to include manual object factory registrations.Python wrapping does include
UseITK.cmake
and default registers factories, therefore manual registrations are not required in ITK Python testing but may be required for remote module consumption. This will be investigated with changes toigenerator.py
in a subsequent PR. Further discussion on object factory architecture and behavior can be found at https://discourse.itk.org/t/proposal-to-improve-itk-factory-registration-cmake-infrastructure/4546/4.PR Checklist
Refer to the ITK Software Guide for
further development details if necessary.