| Keep track of stages of initialization
| to differentiate between
|
| (a) Re-entrant calls to GlobalInit
| (e.g. caller registers a Caffe2 init
| function which might in turn indirectly
| invoke GlobalInit).
|
| (b) Successive calls to GlobalInit,
| which are handled as documented in init.h.
|
| ———–
| @note
|
| this is NOT attempting to address thread-safety,
| see comments in init.h.
|
| ———–
| @brief
|
| Initialize the global environment
| of caffe2.
|
| Caffe2 uses a registration pattern
| for initialization functions. Custom
| initialization functions should take
| the signature bool (func)(int, char***)
| where the pointers to argc and argv are
| passed in. Caffe2 then runs the initialization
| in three phases:
|
| (1) Functions registered with
| REGISTER_CAFFE2_EARLY_INIT_FUNCTION.
|
| Note that since it is possible the logger
| is not initialized yet, any logging
| in such early init functions may not
| be printed correctly.
|
| (2) Parses Caffe-specific commandline
| flags, and initializes caffe logging.
|
| (3) Functions registered with
| REGISTER_CAFFE2_INIT_FUNCTION.
|
| If there is something wrong at each stage,
| the function returns false. If the global
| initialization has already been run,
| the function returns false as well.
|
| GlobalInit is re-entrant safe; a re-entrant
| call will no-op and exit.
|
| GlobalInit is safe to call multiple
| times but not idempotent; successive
| calls will parse flags and re-set caffe2
| logging levels from flags as needed,
| but NOT re-run early init and init functions.
|
| GlobalInit is also thread-safe and
| can be called concurrently.
|
| ———–
| @brief
|
| Initialize the global environment
| without command line arguments
|
| This is a version of the GlobalInit where
| no argument is passed in.
|
| On mobile devices, use this global init,
| since we cannot pass the command line
| options to caffe2, no arguments are
| passed.
|