From: Yangqing Jia Date: Mon, 23 Sep 2013 22:16:46 +0000 (-0700) Subject: layer_factory, and misc update X-Git-Tag: submit/tizen/20180823.020014~1017 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cdcb10a1af8cdb3bf1a1201588a724d0fbc24a59;p=platform%2Fupstream%2Fcaffeonacl.git layer_factory, and misc update --- diff --git a/src/caffe/blob.hpp b/src/caffe/blob.hpp index 3320d07..57ced66 100644 --- a/src/caffe/blob.hpp +++ b/src/caffe/blob.hpp @@ -1,5 +1,5 @@ -#ifndef CAFFE_BLOB_HPP -#define CAFFE_BLOB_HPP +#ifndef CAFFE_BLOB_HPP_ +#define CAFFE_BLOB_HPP_ #include "caffe/common.hpp" #include "caffe/syncedmem.hpp" @@ -50,6 +50,7 @@ class Blob { void Update(); void FromProto(const BlobProto& proto); void ToProto(BlobProto* proto); + private: shared_ptr data_; shared_ptr diff_; diff --git a/src/caffe/common.hpp b/src/caffe/common.hpp index be0797f..95fd73a 100644 --- a/src/caffe/common.hpp +++ b/src/caffe/common.hpp @@ -26,6 +26,7 @@ #define NOT_IMPLEMENTED LOG(FATAL) << "Not Implemented Yet" + namespace caffe { // We will use the boost shared_ptr instead of the new C++11 one mainly @@ -46,20 +47,32 @@ class Caffe { ~Caffe(); static Caffe& Get(); enum Brew { CPU, GPU }; - enum Phase { TRAIN, TEST}; + enum Phase { TRAIN, TEST }; - // The getters for the variables. + // The getters for the variables. + // Returns the cublas handle. static cublasHandle_t cublas_handle(); + // Returns the curand generator. static curandGenerator_t curand_generator(); + // Returns the MKL random stream. static VSLStreamStatePtr vsl_stream(); + // Returns the mode: running on CPU or GPU. static Brew mode(); + // Returns the phase: TRAIN or TEST. static Phase phase(); // The setters for the variables + // Sets the mode. static void set_mode(Brew mode); + // Sets the phase. static void set_phase(Phase phase); + // Sets the random seed of both MKL and curand static void set_random_seed(const unsigned int seed); + private: + // The private constructor to avoid duplicate instantiation. Caffe(); + + protected: static shared_ptr singleton_; cublasHandle_t cublas_handle_; curandGenerator_t curand_generator_; @@ -68,6 +81,7 @@ class Caffe { Phase phase_; }; + } // namespace caffe #endif // CAFFE_COMMON_HPP_ diff --git a/src/caffe/layer.hpp b/src/caffe/layer.hpp index d86ccdc..7772130 100644 --- a/src/caffe/layer.hpp +++ b/src/caffe/layer.hpp @@ -97,6 +97,7 @@ inline Dtype Layer::Backward(const vector*>& top, } }; + } // namespace caffe #endif // CAFFE_LAYER_H_ diff --git a/src/caffe/syncedmem.hpp b/src/caffe/syncedmem.hpp index c217691..0d9fdd3 100644 --- a/src/caffe/syncedmem.hpp +++ b/src/caffe/syncedmem.hpp @@ -1,5 +1,5 @@ -#ifndef CAFFE_SYNCEDMEM_HPP -#define CAFFE_SYNCEDMEM_HPP +#ifndef CAFFE_SYNCEDMEM_HPP_ +#define CAFFE_SYNCEDMEM_HPP_ namespace caffe {