/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
caffe2
/
core
/
/usr/local/lib64/python3.6/site-packages/torch/include/caffe2/core
mkdir
upload
Name
Size
Mode
Actions
allocator.h
136
0644
edit
dl
rm
blob.h
4168
0644
edit
dl
rm
blob_serialization.h
10791
0644
edit
dl
rm
blob_serializer_base.h
3905
0644
edit
dl
rm
blob_stats.h
1127
0644
edit
dl
rm
common.h
4329
0644
edit
dl
rm
common_cudnn.h
9893
0644
edit
dl
rm
common_gpu.h
21414
0644
edit
dl
rm
common_omp.h
156
0644
edit
dl
rm
context.h
6174
0644
edit
dl
rm
context_base.h
4382
0644
edit
dl
rm
context_gpu.h
11014
0644
edit
dl
rm
cudnn_wrappers.h
6956
0644
edit
dl
rm
db.h
9352
0644
edit
dl
rm
distributions_stubs.h
2161
0644
edit
dl
rm
event.h
12420
0644
edit
dl
rm
event_cpu.h
1192
0644
edit
dl
rm
export_c10_op_to_caffe2.h
9487
0644
edit
dl
rm
export_caffe2_op_to_c10.h
11101
0644
edit
dl
rm
flags.h
74
0644
edit
dl
rm
graph.h
5258
0644
edit
dl
rm
init.h
6496
0644
edit
dl
rm
logging.h
75
0644
edit
dl
rm
macros.h
3426
0644
edit
dl
rm
memonger.h
817
0644
edit
dl
rm
module.h
2473
0644
edit
dl
rm
net.h
4634
0644
edit
dl
rm
net_async_base.h
7397
0644
edit
dl
rm
net_async_scheduling.h
993
0644
edit
dl
rm
net_async_task.h
833
0644
edit
dl
rm
net_async_task_future.h
1925
0644
edit
dl
rm
net_async_task_graph.h
2253
0644
edit
dl
rm
net_async_tracing.h
5093
0644
edit
dl
rm
net_dag_utils.h
2146
0644
edit
dl
rm
net_parallel.h
2144
0644
edit
dl
rm
net_simple.h
2606
0644
edit
dl
rm
net_simple_refcount.h
2097
0644
edit
dl
rm
numa.h
72
0644
edit
dl
rm
observer.h
3809
0644
edit
dl
rm
operator.h
58872
0644
edit
dl
rm
operator_gradient.h
10222
0644
edit
dl
rm
operator_schema.h
18477
0644
edit
dl
rm
plan_executor.h
219
0644
edit
dl
rm
prof_dag_counters.h
2751
0644
edit
dl
rm
qtensor.h
6615
0644
edit
dl
rm
qtensor_serialization.h
2624
0644
edit
dl
rm
scope_guard.h
4675
0644
edit
dl
rm
static_tracepoint.h
398
0644
edit
dl
rm
static_tracepoint_elfx86.h
5555
0644
edit
dl
rm
stats.h
10365
0644
edit
dl
rm
storage.h
733
0644
edit
dl
rm
tensor.h
18668
0644
edit
dl
rm
tensor_impl.h
351
0644
edit
dl
rm
tensor_int8.h
450
0644
edit
dl
rm
test_utils.h
6285
0644
edit
dl
rm
timer.h
1218
0644
edit
dl
rm
transform.h
5741
0644
edit
dl
rm
types.h
2248
0644
edit
dl
rm
workspace.h
11305
0644
edit
dl
rm
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<std::pair<InitFunction, const char*>>& 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<std::pair<InitFunction, const char*> > early_init_functions_; vector<std::pair<InitFunction, const char*> > init_functions_; std::unordered_map<std::string, InitFunction> 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_
Save
cmd:
run