Skip to content

Commit

Permalink
Add new "null" convolver
Browse files Browse the repository at this point in the history
The new "null" convolver (implemented by the NULLConvolver class) does
no convolution, and instead returns the source image unmodified. This is
useful for testing Model overheads, like in the case of the "null"
profile.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
  • Loading branch information
rtobar committed Jan 6, 2021
1 parent 505a7d2 commit 6b1b413
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.rst
Expand Up @@ -5,6 +5,13 @@ Changelog
.. highlight:: cpp
.. namespace:: profit

.. rubric:: Development version

* A new ``null`` convolver has been added
that does no convolution
and simply returns the source image unmodified.
This is only useful for testing.

.. rubric:: 1.9.3

* A bug in the OpenCL implementation of the radial profiles
Expand Down
1 change: 1 addition & 0 deletions src/apps/profit-cli.cpp
Expand Up @@ -215,6 +215,7 @@ The following convolver types are supported:
* brute-old: An older, slower brute-force convolver (used only for comparisons)
* opencl: An OpenCL-based brute-force convolver
* fft: An FFT-based convolver
* null: A no-op convolver, useful for testing
Profiles should be specified as follows (parts between [] are optional):
Expand Down
10 changes: 10 additions & 0 deletions src/profit/convolve.cpp
Expand Up @@ -518,6 +518,11 @@ Image OpenCLLocalConvolver::_clpadded_convolve(const Image &src, const Image &kr

#endif // PROFIT_OPENCL

Image NullConvolver::convolve_impl(const Image &src, const Image &krn, const Mask &mask, bool crop, Point &offset_out)
{
return src;
}

ConvolverPtr create_convolver(const ConvolverType type, const ConvolverCreationPreferences &prefs)
{
switch(type) {
Expand Down Expand Up @@ -553,6 +558,8 @@ ConvolverPtr create_convolver(const ConvolverType type, const ConvolverCreationP
prefs.effort, prefs.omp_threads,
prefs.reuse_krn_fft);
#endif // PROFIT_FFTW
case NO_OP:
return std::make_shared<NullConvolver>();
default:
// Shouldn't happen
throw invalid_parameter("Unsupported convolver type: " + std::to_string(type));
Expand All @@ -577,6 +584,9 @@ ConvolverPtr create_convolver(const std::string &type, const ConvolverCreationPr
return create_convolver(FFT, prefs);
}
#endif // PROFIT_FFTW
else if (type == "null") {
return create_convolver(NO_OP, prefs);
}

std::ostringstream os;
os << "Convolver of type " << type << " is not supported";
Expand Down
3 changes: 3 additions & 0 deletions src/profit/convolve.h
Expand Up @@ -54,6 +54,9 @@ enum ConvolverType {

/// @copydoc FFTConvolver
FFT,

/// @copydoc NULLConvolver
NO_OP
};

/**
Expand Down
9 changes: 9 additions & 0 deletions src/profit/convolver_impl.h
Expand Up @@ -187,4 +187,13 @@ class OpenCLLocalConvolver : public Convolver {

#endif // PROFIT_OPENCL

/**
* A convolver that doesn't convolve, useful for testing.
*/
class NullConvolver : public Convolver
{
public:
Image convolve_impl(const Image &src, const Image &krn, const Mask &mask, bool crop = true, Point &offset_out = NO_OFFSET) override;
};

}

0 comments on commit 6b1b413

Please sign in to comment.