Commandline flags support for Caffe2. More...
#include "caffe2/core/registry.h"
Go to the source code of this file.
Data Structures | |
class | caffe2::Caffe2FlagParser |
Namespaces | |
caffe2 | |
Simple registry implementation in Caffe2 that uses static variables to register object creators during program initialization time. | |
Functions | |
void | caffe2::SetUsageMessage (const string &str) |
Sets the usage message when a commandline tool is called with "--help". | |
const char * | caffe2::UsageMessage () |
Returns the usage message for the commandline tool set by SetUsageMessage. | |
bool | caffe2::ParseCaffeCommandLineFlags (int *pargc, char ***pargv) |
Parses the commandline flags. More... | |
bool | caffe2::CommandLineFlagsHasBeenParsed () |
Checks if the commandline flags has already been passed. | |
caffe2::CAFFE_DECLARE_REGISTRY (Caffe2FlagsRegistry, Caffe2FlagParser, const string &) | |
Commandline flags support for Caffe2.
This is a portable commandline flags tool for caffe2, so we can optionally choose to use gflags or a lightweighted custom implementation if gflags is not possible on a certain platform. If you have gflags installed, set the macro CAFFE2_USE_GFLAGS will seamlessly route everything to gflags.
To define a flag foo of type bool default to true, do the following in the global namespace: CAFFE2_DEFINE_bool(foo, true, "An example.");
To use it in another .cc file, you can use CAFFE2_DECLARE_* as follows: CAFFE2_DECLARE_bool(foo);
In both cases, you can then access the flag via caffe2::FLAGS_foo.
Definition in file flags.h.
#define CAFFE2_DECLARE_typed_var | ( | type, | |
name | |||
) |
#define CAFFE2_DEFINE_typed_var | ( | type, | |
name, | |||
default_value, | |||
help_str | |||
) |