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_UNKNOWN -1
27 #define BINDING_TYPE BINDING_TYPE_UNKNOWN
30 #if (BINDING_TYPE == BINDING_TYPE_CLI) // This is a command-line executable.
35 #define PRINT_PARAM_STRING mlpack::bindings::cli::ParamString
36 #define PRINT_PARAM_VALUE mlpack::bindings::cli::PrintValue
37 #define PRINT_CALL mlpack::bindings::cli::ProgramCall
38 #define PRINT_DATASET mlpack::bindings::cli::PrintDataset
39 #define PRINT_MODEL mlpack::bindings::cli::PrintModel
40 #define BINDING_IGNORE_CHECK mlpack::bindings::cli::IgnoreCheck
51 static const std::string testName =
"";
56 static void mlpackMain();
58 int main(
int argc,
char** argv)
75 #elif(BINDING_TYPE == BINDING_TYPE_TEST) // This is a unit test.
82 #define PRINT_PARAM_STRING(A) std::string(" ")
83 #define PRINT_PARAM_VALUE(A, B) std::string(" ")
84 #define PRINT_DATASET(A) std::string(" ")
85 #define PRINT_MODEL(A) std::string(" ")
86 #define PRINT_CALL(...) std::string(" ")
87 #define BINDING_IGNORE_CHECK mlpack::bindings::tests::IgnoreCheck
102 #define PROGRAM_INFO(NAME, DESC) static mlpack::util::ProgramDoc \
103 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, \
104 []() { return DESC; });
106 #elif(BINDING_TYPE == BINDING_TYPE_PYX) // This is a Python binding.
111 #define PRINT_PARAM_STRING mlpack::bindings::python::ParamString
112 #define PRINT_PARAM_VALUE mlpack::bindings::python::PrintValue
113 #define PRINT_DATASET mlpack::bindings::python::PrintDataset
114 #define PRINT_MODEL mlpack::bindings::python::PrintModel
115 #define PRINT_CALL mlpack::bindings::python::ProgramCall
116 #define BINDING_IGNORE_CHECK mlpack::bindings::python::IgnoreCheck
127 static const std::string testName =
"";
131 #define PROGRAM_INFO(NAME, DESC) static mlpack::util::ProgramDoc \
132 cli_programdoc_dummy_object = mlpack::util::ProgramDoc(NAME, \
133 []() { return DESC; }); \
135 namespace bindings { \
137 std::string programName = NAME; \
142 PARAM_FLAG(
"verbose",
"Display informational messages and the full list of "
143 "parameters and timers at the end of execution.",
"v");
144 PARAM_FLAG(
"copy_all_inputs",
"If specified, all input parameters will be deep"
145 " copied before the method is run. This is useful for debugging problems "
146 "where the input parameters are being modified by the algorithm, but can "
147 "slow down the code.",
"");
153 #error "Unknown binding type! Be sure BINDING_TYPE is defined if you are " \
154 "including <mlpack/core/util/mlpack_main.hpp>.";
void EndProgram()
Handle command-line program termination.
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_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.