xref: /aosp_15_r20/external/pytorch/c10/util/flags_use_gflags.cpp (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1 #include <c10/macros/Macros.h>
2 
3 #ifdef C10_USE_GFLAGS
4 
5 #include <c10/util/Flags.h>
6 #include <string>
7 
8 namespace c10 {
9 
10 using std::string;
11 
SetUsageMessage(const string & str)12 C10_EXPORT void SetUsageMessage(const string& str) {
13   if (UsageMessage() != nullptr) {
14     // Usage message has already been set, so we will simply return.
15     return;
16   }
17   gflags::SetUsageMessage(str);
18 }
19 
UsageMessage()20 C10_EXPORT const char* UsageMessage() {
21   return gflags::ProgramUsage();
22 }
23 
ParseCommandLineFlags(int * pargc,char *** pargv)24 C10_EXPORT bool ParseCommandLineFlags(int* pargc, char*** pargv) {
25   // In case there is no commandline flags to parse, simply return.
26   if (*pargc == 0)
27     return true;
28   return gflags::ParseCommandLineFlags(pargc, pargv, true);
29 }
30 
CommandLineFlagsHasBeenParsed()31 C10_EXPORT bool CommandLineFlagsHasBeenParsed() {
32   // There is no way we query gflags right now, so we will simply return true.
33   return true;
34 }
35 
36 } // namespace c10
37 #endif // C10_USE_GFLAGS
38