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
Adapt virtually everything else in mlpack to header-only #3233
Conversation
Nice work. If this hasn't been addressed previously, I suggest simplifying how mlpack is consumed by users, so that a straightforward This simplification would replace users manually selecting a subset of headers from the multitude of available headers. The manual selection is tedious and can be error prone, especially for newbies or time-constrained users that just want to get their stuff running quickly. |
Let me do some timing tests to convince myself that including extra headers from all of mlpack doesn't make a significant compilation time difference (I suspect it won't), and then I will do that. That, plus updating the CMake configuration, I think are the last things that need to be done before we can release mlpack 4. |
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>
related: #3237 (comment) |
This fixes the failing tests (or it should).
@rcurtin This all looks fine to me. I still suggest to make mlpack easier to use, by including everything via |
Thanks, I still have two things to do here---one is to try the |
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.
Second approval provided automatically after 24 hours. 👍
Since all the tests pass, I'll merge this now---the idea of a complete |
This PR nearly finishes making everything in mlpack header-only! It is a follow-up to #3091 and #3195. I've converted all files except one (trivial) file to header-only, so now libmlpack.so contains I think only one function definition. (I didn't remove that function, because I wanted to separate CMake changes into a separate PR, and if libmlpack.so has no files, CMake doesn't like that and fails to build. So, I left just one...)
Not every adaptation here was simple, so I'll detail each non-trivial change below:
The
Log
object used to be a class, but now it's a namespace that contains translation-unit-local static singletonsDebug
,Info
,Warn
, andFatal
. From a developer/user perspective, nothing is changed and they are still used the same way.Any other singletons, like
IO
andTimer
, are now held in each individual translation unit, as opposed to just one inlibmlpack.so
. That's okay, and all of our bindings work just fine with that.The
CheckInputMatrices()
function inutil/
had a dependency ondata/
, and forward declarations would not solve this. So, I instead madeCheckInputMatrices()
call out to a forward-defined function indata/
calledCheckCategoricalParam()
. The functionality is the same as before.The backtrace code used some global objects and the
Backtrace
class itself had all its functions declared asstatic
. But it was only ever used in a non-static context, so I just moved the global objects insideBacktrace
and it works fine.