have rng_stream initialize RNG if not already initialized
authorJeff Donahue <jeff.donahue@gmail.com>
Tue, 8 Apr 2014 21:24:48 +0000 (14:24 -0700)
committerJeff Donahue <jeff.donahue@gmail.com>
Wed, 9 Apr 2014 03:17:17 +0000 (20:17 -0700)
include/caffe/common.hpp

index 1829026..af7dcc4 100644 (file)
@@ -96,6 +96,9 @@ class Caffe {
 
   // Getters for boost rng, curand, and cublas handles
   inline static const RNG& rng_stream() {
+    if (!Get().random_generator_) {
+      Get().random_generator_.reset(new RNG());
+    }
     return *(Get().random_generator_);
   }
   inline static cublasHandle_t cublas_handle() { return Get().cublas_handle_; }