Caffe2 - C++ API
A deep learning, cross platform ML framework
flags_use_gflags.cpp
1 #include "c10/util/Flags.h"
2 
3 #include <string>
4 
5 #include "c10/macros/Macros.h"
6 
7 #ifdef C10_USE_GFLAGS
8 
9 namespace c10 {
10 
11 using std::string;
12 
13 C10_EXPORT void SetUsageMessage(const string& str) {
14  if (UsageMessage() != nullptr) {
15  // Usage message has already been set, so we will simply return.
16  return;
17  }
18  gflags::SetUsageMessage(str);
19 }
20 
21 C10_EXPORT const char* UsageMessage() {
22  return gflags::ProgramUsage();
23 }
24 
25 C10_EXPORT bool ParseCommandLineFlags(int* pargc, char*** pargv) {
26  // In case there is no commandline flags to parse, simply return.
27  if (*pargc == 0)
28  return true;
29  return gflags::ParseCommandLineFlags(pargc, pargv, true);
30 }
31 
32 C10_EXPORT bool CommandLineFlagsHasBeenParsed() {
33  // There is no way we query gflags right now, so we will simply return true.
34  return true;
35 }
36 
37 } // namespace c10
38 #endif // C10_USE_GFLAGS
C10_API void SetUsageMessage(const std::string &str)
Sets the usage message when a commandline tool is called with "--help".
C10_API const char * UsageMessage()
Returns the usage message for the commandline tool set by SetUsageMessage.
To register your own kernel for an operator, do in one (!) cpp file: C10_REGISTER_KERNEL(OperatorHand...
Definition: alias_info.h:7
C10_API bool CommandLineFlagsHasBeenParsed()
Checks if the commandline flags has already been passed.
C10_API bool ParseCommandLineFlags(int *pargc, char ***pargv)
Parses the commandline flags.