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_MARKDOWN 128 25 #define BINDING_TYPE_UNKNOWN -1 28 #define BINDING_TYPE BINDING_TYPE_UNKNOWN 31 #if (BINDING_TYPE == BINDING_TYPE_CLI) // This is a command-line executable. 34 #define BINDING_MATRIX_TRANSPOSED true 43 #define PRINT_PARAM_STRING mlpack::bindings::cli::ParamString 49 #define PRINT_PARAM_VALUE mlpack::bindings::cli::PrintValue 58 #define PRINT_CALL mlpack::bindings::cli::ProgramCall 64 #define PRINT_DATASET mlpack::bindings::cli::PrintDataset 70 #define PRINT_MODEL mlpack::bindings::cli::PrintModel 76 #define BINDING_IGNORE_CHECK mlpack::bindings::cli::IgnoreCheck 87 static const std::string testName =
"";
92 static void mlpackMain();
94 int main(
int argc,
char** argv)
111 #elif(BINDING_TYPE == BINDING_TYPE_TEST) // This is a unit test. 114 #define BINDING_MATRIX_TRANSPOSED false 121 #define PRINT_PARAM_STRING(A) std::string(" ") 122 #define PRINT_PARAM_VALUE(A, B) std::string(" ") 123 #define PRINT_DATASET(A) std::string(" ") 124 #define PRINT_MODEL(A) std::string(" ") 133 #define PRINT_CALL(...) std::string(" ") 139 #define BINDING_IGNORE_CHECK mlpack::bindings::tests::IgnoreCheck 154 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) \ 155 static mlpack::util::ProgramDoc \ 156 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, SHORT_DESC, \ 157 []() { return DESC; }, { __VA_ARGS__ }) 159 #elif(BINDING_TYPE == BINDING_TYPE_PYX) // This is a Python binding. 162 #define BINDING_MATRIX_TRANSPOSED true 171 #define PRINT_PARAM_STRING mlpack::bindings::python::ParamString 177 #define PRINT_PARAM_VALUE mlpack::bindings::python::PrintValue 183 #define PRINT_DATASET mlpack::bindings::python::PrintDataset 189 #define PRINT_MODEL mlpack::bindings::python::PrintModel 198 #define PRINT_CALL mlpack::bindings::python::ProgramCall 204 #define BINDING_IGNORE_CHECK mlpack::bindings::python::IgnoreCheck 215 static const std::string testName =
"";
219 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) \ 220 static mlpack::util::ProgramDoc \ 221 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, SHORT_DESC, \ 222 []() { return DESC; }, { __VA_ARGS__ }); \ 224 namespace bindings { \ 226 std::string programName = NAME; \ 231 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of " 232 "parameters and timers at the end of execution.",
"v");
233 PARAM_FLAG(
"copy_all_inputs",
"If specified, all input parameters will be deep" 234 " copied before the method is run. This is useful for debugging problems " 235 "where the input parameters are being modified by the algorithm, but can " 236 "slow down the code.",
"");
240 #elif BINDING_TYPE == BINDING_TYPE_MARKDOWN 244 #error "BINDING_NAME must be defined when BINDING_TYPE is Markdown!" 254 #define PRINT_PARAM_STRING mlpack::bindings::markdown::ParamString 260 #define PRINT_PARAM_VALUE mlpack::bindings::markdown::PrintValue 266 #define PRINT_DATASET mlpack::bindings::markdown::PrintDataset 272 #define PRINT_MODEL mlpack::bindings::markdown::PrintModel 281 #define PRINT_CALL mlpack::bindings::markdown::ProgramCall 287 #define BINDING_IGNORE_CHECK mlpack::bindings::markdown::IgnoreCheck 290 #define BINDING_MATRIX_TRANSPOSED true 305 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) static \ 306 mlpack::bindings::markdown::ProgramDocWrapper \ 307 cli_programdoc_dummy_object = \ 308 mlpack::bindings::markdown::ProgramDocWrapper(BINDING_NAME, NAME, \ 309 SHORT_DESC, []() { return DESC; }, { __VA_ARGS__ }); \ 311 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of " 312 "parameters and timers at the end of execution.",
"v");
315 PARAM_FLAG(
"help",
"Default help info.",
"h");
317 PARAM_FLAG(
"version",
"Display the version of mlpack.",
"V");
320 PARAM_FLAG(
"copy_all_inputs",
"If specified, all input parameters will be deep" 321 " copied before the method is run. This is useful for debugging problems " 322 "where the input parameters are being modified by the algorithm, but can " 323 "slow down the code.",
"");
327 #error "Unknown binding type! Be sure BINDING_TYPE is defined if you are " \ 328 "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.