18 #ifndef MLPACK_CORE_UTIL_MLPACK_MAIN_HPP
19 #define MLPACK_CORE_UTIL_MLPACK_MAIN_HPP
21 #define BINDING_TYPE_CLI 0
22 #define BINDING_TYPE_TEST 1
23 #define BINDING_TYPE_PYX 2
24 #define BINDING_TYPE_JL 3
25 #define BINDING_TYPE_MARKDOWN 128
26 #define BINDING_TYPE_UNKNOWN -1
29 #define BINDING_TYPE BINDING_TYPE_UNKNOWN
32 #if (BINDING_TYPE == BINDING_TYPE_CLI) // This is a command-line executable.
35 #define BINDING_MATRIX_TRANSPOSED true
44 #define PRINT_PARAM_STRING mlpack::bindings::cli::ParamString
50 #define PRINT_PARAM_VALUE mlpack::bindings::cli::PrintValue
59 #define PRINT_CALL mlpack::bindings::cli::ProgramCall
65 #define PRINT_DATASET mlpack::bindings::cli::PrintDataset
71 #define PRINT_MODEL mlpack::bindings::cli::PrintModel
77 #define BINDING_IGNORE_CHECK mlpack::bindings::cli::IgnoreCheck
93 static void mlpackMain();
95 int main(
int argc,
char** argv)
112 #elif(BINDING_TYPE == BINDING_TYPE_TEST) // This is a unit test.
115 #define BINDING_MATRIX_TRANSPOSED false
122 #define PRINT_PARAM_STRING(A) std::string(" ")
123 #define PRINT_PARAM_VALUE(A, B) std::string(" ")
124 #define PRINT_DATASET(A) std::string(" ")
125 #define PRINT_MODEL(A) std::string(" ")
134 #define PRINT_CALL(...) std::string(" ")
140 #define BINDING_IGNORE_CHECK mlpack::bindings::tests::IgnoreCheck
155 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) \
156 static mlpack::util::ProgramDoc \
157 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, SHORT_DESC, \
158 []() { return DESC; }, { __VA_ARGS__ })
160 #elif(BINDING_TYPE == BINDING_TYPE_PYX) // This is a Python binding.
163 #define BINDING_MATRIX_TRANSPOSED true
172 #define PRINT_PARAM_STRING mlpack::bindings::python::ParamString
178 #define PRINT_PARAM_VALUE mlpack::bindings::python::PrintValue
184 #define PRINT_DATASET mlpack::bindings::python::PrintDataset
190 #define PRINT_MODEL mlpack::bindings::python::PrintModel
199 #define PRINT_CALL mlpack::bindings::python::ProgramCall
205 #define BINDING_IGNORE_CHECK mlpack::bindings::python::IgnoreCheck
220 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) \
221 static mlpack::util::ProgramDoc \
222 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, SHORT_DESC, \
223 []() { return DESC; }, { __VA_ARGS__ }); \
225 namespace bindings { \
227 std::string programName = NAME; \
232 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of "
233 "parameters and timers at the end of execution.",
"v");
234 PARAM_FLAG(
"copy_all_inputs",
"If specified, all input parameters will be deep"
235 " copied before the method is run. This is useful for debugging problems "
236 "where the input parameters are being modified by the algorithm, but can "
237 "slow down the code.",
"");
241 #elif(BINDING_TYPE == BINDING_TYPE_JL) // This is a Julia binding.
244 #define BINDING_MATRIX_TRANSPOSED true
249 #define PRINT_PARAM_STRING mlpack::bindings::julia::ParamString
250 #define PRINT_PARAM_VALUE mlpack::bindings::julia::PrintValue
251 #define PRINT_DATASET mlpack::bindings::julia::PrintDataset
252 #define PRINT_MODEL mlpack::bindings::julia::PrintModel
253 #define PRINT_CALL mlpack::bindings::julia::ProgramCall
254 #define BINDING_IGNORE_CHECK mlpack::bindings::julia::IgnoreCheck
269 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) static \
270 mlpack::util::ProgramDoc \
271 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, SHORT_DESC, \
272 []() { return DESC; }, { __VA_ARGS__ }); \
274 namespace bindings { \
276 std::string programName = NAME; \
281 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of "
282 "parameters and timers at the end of execution.",
"v");
284 #elif BINDING_TYPE == BINDING_TYPE_MARKDOWN
288 #error "BINDING_NAME must be defined when BINDING_TYPE is Markdown!"
292 #define BINDING_MATRIX_TRANSPOSED true
301 #define PRINT_PARAM_STRING mlpack::bindings::markdown::ParamString
307 #define PRINT_PARAM_VALUE mlpack::bindings::markdown::PrintValue
313 #define PRINT_DATASET mlpack::bindings::markdown::PrintDataset
319 #define PRINT_MODEL mlpack::bindings::markdown::PrintModel
328 #define PRINT_CALL mlpack::bindings::markdown::ProgramCall
334 #define BINDING_IGNORE_CHECK mlpack::bindings::markdown::IgnoreCheck
337 #define BINDING_MATRIX_TRANSPOSED true
352 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) static \
353 mlpack::bindings::markdown::ProgramDocWrapper \
354 cli_programdoc_dummy_object = \
355 mlpack::bindings::markdown::ProgramDocWrapper(BINDING_NAME, NAME, \
356 SHORT_DESC, []() { return DESC; }, { __VA_ARGS__ }); \
358 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of "
359 "parameters and timers at the end of execution.",
"v");
362 PARAM_FLAG(
"help",
"Default help info.",
"h");
364 PARAM_FLAG(
"version",
"Display the version of mlpack.",
"V");
367 PARAM_FLAG(
"copy_all_inputs",
"If specified, all input parameters will be deep"
368 " copied before the method is run. This is useful for debugging problems "
369 "where the input parameters are being modified by the algorithm, but can "
370 "slow down the code.",
"");
374 #error "Unknown binding type! Be sure BINDING_TYPE is defined if you are " \
375 "including <mlpack/core/util/mlpack_main.hpp>.";
void EndProgram()
Handle command-line program termination.
The Markdown option class.
void ParseCommandLine(int argc, char **argv)
Parse the command line, setting all of the options inside of the CLI object to their appropriate give...
static void EnableTiming()
Enable timing of mlpack programs.
#define PARAM_STRING_IN(ID, DESC, ALIAS, DEF)
Define a string input parameter.
#define PARAM_FLAG(ID, DESC, ALIAS)
Define a flag parameter.
A static object whose constructor registers a parameter with the CLI class.
A static object whose constructor registers a parameter with the CLI class.
static void Start(const std::string &name)
Start the given timer.
string(REGEX REPLACE".*#define MLPACK_VERSION_MINOR ([0-9]+).*""\\1"MLPACK_VERSION_MINOR"${VERSION_HPP_CONTENTS}") string(REGEX REPLACE".* "\\1" MLPACK_VERSION_PATCH "$