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. 36 #define PRINT_PARAM_STRING mlpack::bindings::cli::ParamString 37 #define PRINT_PARAM_VALUE mlpack::bindings::cli::PrintValue 38 #define PRINT_CALL mlpack::bindings::cli::ProgramCall 39 #define PRINT_DATASET mlpack::bindings::cli::PrintDataset 40 #define PRINT_MODEL mlpack::bindings::cli::PrintModel 41 #define BINDING_IGNORE_CHECK mlpack::bindings::cli::IgnoreCheck 52 static const std::string testName =
"";
57 static void mlpackMain();
59 int main(
int argc,
char** argv)
76 #elif(BINDING_TYPE == BINDING_TYPE_TEST) // This is a unit test. 83 #define PRINT_PARAM_STRING(A) std::string(" ") 84 #define PRINT_PARAM_VALUE(A, B) std::string(" ") 85 #define PRINT_DATASET(A) std::string(" ") 86 #define PRINT_MODEL(A) std::string(" ") 87 #define PRINT_CALL(...) std::string(" ") 88 #define BINDING_IGNORE_CHECK mlpack::bindings::tests::IgnoreCheck 103 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) \ 104 static mlpack::util::ProgramDoc \ 105 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, SHORT_DESC, \ 106 []() { return DESC; }, { __VA_ARGS__ }) 108 #elif(BINDING_TYPE == BINDING_TYPE_PYX) // This is a Python binding. 113 #define PRINT_PARAM_STRING mlpack::bindings::python::ParamString 114 #define PRINT_PARAM_VALUE mlpack::bindings::python::PrintValue 115 #define PRINT_DATASET mlpack::bindings::python::PrintDataset 116 #define PRINT_MODEL mlpack::bindings::python::PrintModel 117 #define PRINT_CALL mlpack::bindings::python::ProgramCall 118 #define BINDING_IGNORE_CHECK mlpack::bindings::python::IgnoreCheck 129 static const std::string testName =
"";
133 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) \ 134 static mlpack::util::ProgramDoc \ 135 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, SHORT_DESC, \ 136 []() { return DESC; }, { __VA_ARGS__ }); \ 138 namespace bindings { \ 140 std::string programName = NAME; \ 145 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of " 146 "parameters and timers at the end of execution.",
"v");
147 PARAM_FLAG(
"copy_all_inputs",
"If specified, all input parameters will be deep" 148 " copied before the method is run. This is useful for debugging problems " 149 "where the input parameters are being modified by the algorithm, but can " 150 "slow down the code.",
"");
154 #elif BINDING_TYPE == BINDING_TYPE_MARKDOWN 157 #define BINDING_MATRIX_TRANSPOSED true 161 #error "BINDING_NAME must be defined when BINDING_TYPE is Markdown!" 167 #define PRINT_PARAM_STRING mlpack::bindings::markdown::ParamString 168 #define PRINT_PARAM_VALUE mlpack::bindings::markdown::PrintValue 169 #define PRINT_DATASET mlpack::bindings::markdown::PrintDataset 170 #define PRINT_MODEL mlpack::bindings::markdown::PrintModel 171 #define PRINT_CALL mlpack::bindings::markdown::ProgramCall 172 #define BINDING_IGNORE_CHECK mlpack::bindings::markdown::IgnoreCheck 187 #define PROGRAM_INFO(NAME, SHORT_DESC, DESC, ...) static \ 188 mlpack::bindings::markdown::ProgramDocWrapper \ 189 cli_programdoc_dummy_object = \ 190 mlpack::bindings::markdown::ProgramDocWrapper(BINDING_NAME, NAME, \ 191 SHORT_DESC, []() { return DESC; }, { __VA_ARGS__ }); \ 193 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of " 194 "parameters and timers at the end of execution.",
"v");
197 PARAM_FLAG(
"help",
"Default help info.",
"h");
199 PARAM_FLAG(
"version",
"Display the version of mlpack.",
"V");
202 PARAM_FLAG(
"copy_all_inputs",
"If specified, all input parameters will be deep" 203 " copied before the method is run. This is useful for debugging problems " 204 "where the input parameters are being modified by the algorithm, but can " 205 "slow down the code.",
"");
209 #error "Unknown binding type! Be sure BINDING_TYPE is defined if you are " \ 210 "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.