/usr/local/lib64/python3.6/site-packages/torch/include/caffe2/core
NameSizeModeActions
allocator.h1360644editdlrm
blob.h41680644editdlrm
blob_serialization.h107910644editdlrm
blob_serializer_base.h39050644editdlrm
blob_stats.h11270644editdlrm
common.h43290644editdlrm
common_cudnn.h98930644editdlrm
common_gpu.h214140644editdlrm
common_omp.h1560644editdlrm
context.h61740644editdlrm
context_base.h43820644editdlrm
context_gpu.h110140644editdlrm
cudnn_wrappers.h69560644editdlrm
db.h93520644editdlrm
distributions_stubs.h21610644editdlrm
event.h124200644editdlrm
event_cpu.h11920644editdlrm
export_c10_op_to_caffe2.h94870644editdlrm
export_caffe2_op_to_c10.h111010644editdlrm
flags.h740644editdlrm
graph.h52580644editdlrm
init.h64960644editdlrm
logging.h750644editdlrm
macros.h34260644editdlrm
memonger.h8170644editdlrm
module.h24730644editdlrm
net.h46340644editdlrm
net_async_base.h73970644editdlrm
net_async_scheduling.h9930644editdlrm
net_async_task.h8330644editdlrm
net_async_task_future.h19250644editdlrm
net_async_task_graph.h22530644editdlrm
net_async_tracing.h50930644editdlrm
net_dag_utils.h21460644editdlrm
net_parallel.h21440644editdlrm
net_simple.h26060644editdlrm
net_simple_refcount.h20970644editdlrm
numa.h720644editdlrm
observer.h38090644editdlrm
operator.h588720644editdlrm
operator_gradient.h102220644editdlrm
operator_schema.h184770644editdlrm
plan_executor.h2190644editdlrm
prof_dag_counters.h27510644editdlrm
qtensor.h66150644editdlrm
qtensor_serialization.h26240644editdlrm
scope_guard.h46750644editdlrm
static_tracepoint.h3980644editdlrm
static_tracepoint_elfx86.h55550644editdlrm
stats.h103650644editdlrm
storage.h7330644editdlrm
tensor.h186680644editdlrm
tensor_impl.h3510644editdlrm
tensor_int8.h4500644editdlrm
test_utils.h62850644editdlrm
timer.h12180644editdlrm
transform.h57410644editdlrm
types.h22480644editdlrm
workspace.h113050644editdlrm
Edit: /usr/local/lib64/python3.6/site-packages/torch/include/caffe2/core/init.h (6496B)
#ifndef CAFFE2_CORE_INIT_H_ #define CAFFE2_CORE_INIT_H_ #include "caffe2/core/common.h" #include "caffe2/core/flags.h" #include "caffe2/core/logging.h" namespace caffe2 { namespace internal { class TORCH_API Caffe2InitializeRegistry { public: typedef bool (*InitFunction)(int*, char***); // Registry() is defined in .cpp file to make registration work across // multiple shared libraries loaded with RTLD_LOCAL static Caffe2InitializeRegistry* Registry(); void Register( InitFunction function, bool run_early, const char* description, const char* name = nullptr) { if (name) { named_functions_[name] = function; } if (run_early) { // Disallow registration after GlobalInit of early init functions CAFFE_ENFORCE(!early_init_functions_run_yet_); early_init_functions_.emplace_back(function, description); } else { if (init_functions_run_yet_) { // Run immediately, since GlobalInit already ran. This should be // rare but we want to allow it in some cases. LOG(WARNING) << "Running init function after GlobalInit: " << description; // TODO(orionr): Consider removing argc and argv for non-early // registration. Unfortunately that would require a new InitFunction // typedef, so not making the change right now. // // Note that init doesn't receive argc and argv, so the function // might fail and we want to raise an error in that case. int argc = 0; char** argv = nullptr; bool success = (function)(&argc, &argv); CAFFE_ENFORCE(success); } else { // Wait until GlobalInit to run init_functions_.emplace_back(function, description); } } } bool RunRegisteredEarlyInitFunctions(int* pargc, char*** pargv) { CAFFE_ENFORCE(!early_init_functions_run_yet_); early_init_functions_run_yet_ = true; return RunRegisteredInitFunctionsInternal( early_init_functions_, pargc, pargv); } bool RunRegisteredInitFunctions(int* pargc, char*** pargv) { CAFFE_ENFORCE(!init_functions_run_yet_); init_functions_run_yet_ = true; return RunRegisteredInitFunctionsInternal(init_functions_, pargc, pargv); } bool RunNamedFunction(const char* name, int* pargc, char*** pargv) { if (named_functions_.count(name)) { return named_functions_[name](pargc, pargv); } return false; } private: // Run all registered initialization functions. This has to be called AFTER // all static initialization are finished and main() has started, since we are // using logging. bool RunRegisteredInitFunctionsInternal( vector>& functions, int* pargc, char*** pargv) { for (const auto& init_pair : functions) { VLOG(1) << "Running init function: " << init_pair.second; if (!(*init_pair.first)(pargc, pargv)) { LOG(ERROR) << "Initialization function failed."; return false; } } return true; } Caffe2InitializeRegistry() {} vector > early_init_functions_; vector > init_functions_; std::unordered_map named_functions_; bool early_init_functions_run_yet_ = false; bool init_functions_run_yet_ = false; }; } // namespace internal TORCH_API bool unsafeRunCaffe2InitFunction( const char* name, int* pargc = nullptr, char*** pargv = nullptr); class TORCH_API InitRegisterer { public: InitRegisterer( internal::Caffe2InitializeRegistry::InitFunction function, bool run_early, const char* description, const char* name = nullptr) { internal::Caffe2InitializeRegistry::Registry()->Register( function, run_early, description, name); } }; #define REGISTER_CAFFE2_INIT_FUNCTION(name, function, description) \ namespace { \ ::caffe2::InitRegisterer \ g_caffe2_initregisterer_##name(function, false, description, #name); \ } // namespace #define REGISTER_CAFFE2_EARLY_INIT_FUNCTION(name, function, description) \ namespace { \ ::caffe2::InitRegisterer \ g_caffe2_initregisterer_##name(function, true, description, #name); \ } // namespace /** * @brief Determine whether GlobalInit has already been run */ TORCH_API bool GlobalInitAlreadyRun(); class TORCH_API GlobalInitIsCalledGuard { public: GlobalInitIsCalledGuard() { if (!GlobalInitAlreadyRun()) { LOG(WARNING) << "Caffe2 GlobalInit should be run before any other API calls."; } } }; /** * @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. */ TORCH_API bool GlobalInit(int* pargc, char*** argv); /** * @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. */ TORCH_API bool GlobalInit(); } // namespace caffe2 #endif // CAFFE2_CORE_INIT_H_