Caffe2 - C++ API
A deep learning, cross platform ML framework
context.cc
1 #include "caffe2/core/context.h"
2 
3 #include <atomic>
4 #if defined(_MSC_VER)
5 #include <process.h>
6 #endif
7 
8 namespace caffe2 {
9 
10 uint32_t RandomNumberSeed() {
11  // Originally copied from folly::randomNumberSeed (at 418ad4)
12  // modified to use chrono instead of sys/time.h
13  static std::atomic<uint32_t> seedInput(0);
14  auto tv = std::chrono::system_clock::now().time_since_epoch();
15  uint64_t usec = static_cast<uint64_t>(
16  std::chrono::duration_cast<std::chrono::microseconds>(tv).count());
17  uint32_t tv_sec = usec / 1000000;
18  uint32_t tv_usec = usec % 1000000;
19  const uint32_t kPrime0 = 51551;
20  const uint32_t kPrime1 = 61631;
21  const uint32_t kPrime2 = 64997;
22  const uint32_t kPrime3 = 111857;
23  return kPrime0 * (seedInput++) + kPrime1 * static_cast<uint32_t>(getpid()) +
24  kPrime2 * tv_sec + kPrime3 * tv_usec;
25 }
26 
27 } // namespace caffe2
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
uint32_t RandomNumberSeed()
A function to generate a random number seed that is unique in a best-effort basis, using an ever-incrementing seed and the current time.
Definition: context.cc:10