From: Yangqing Jia Date: Sat, 14 Sep 2013 00:33:52 +0000 (-0700) Subject: some updates X-Git-Tag: submit/tizen/20180823.020014~1081 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dceef03a17ebf35fee2bd69e54b3402fa0be65d1;p=platform%2Fupstream%2Fcaffeonacl.git some updates --- diff --git a/src/caffeine/base.h b/src/caffeine/base.h deleted file mode 100644 index c1fa8b1..0000000 --- a/src/caffeine/base.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef CAFFEINE_BASE_H_ -#define CAFFEINE_BASE_H_ - -#include -#include "caffeine/blob.hpp" -#include "caffeine/proto/layer_param.pb.h" - -using std::vector; - -namespace caffeine { - -template -class Layer { - public: - explicit Layer(const LayerParameter& param) - : initialized_(false), layer_param_(param) {}; - ~Layer(); - virtual void SetUp(vector*>& bottom, - vector*>* top) = 0; - virtual void Forward(vector*>& bottom, - vector*>* top) = 0; - virtual void Predict(vector*>& bottom, - vector*>* top) = 0; - virtual void Backward(vector*>& bottom, - vector*>* top, bool propagate_down) = 0; - protected: - bool initialized_; - // The protobuf that stores the layer parameters - LayerParameter layer_param_; - // The vector that stores the parameters as a set of blobs. - vector > blobs; -}; // class Layer - -} // namespace caffeine - -#endif // CAFFEINE_BASE_H_ diff --git a/src/caffeine/common.hpp b/src/caffeine/common.hpp index 38e6fd1..1aad02a 100644 --- a/src/caffeine/common.hpp +++ b/src/caffeine/common.hpp @@ -1,8 +1,6 @@ #ifndef CAFFEINE_COMMON_HPP_ #define CAFFEINE_COMMON_HPP_ -#include - #include #include #include @@ -21,31 +19,23 @@ using boost::shared_ptr; // A singleton class to hold common caffeine stuff, such as the handler that // caffeine is going to use for cublas. class Caffeine { + public: + ~Caffeine(); + static Caffeine& Get(); + enum Brew { CPU, GPU }; + + // The getters for the variables. + static cublasHandle_t cublas_handle(); + static Brew mode(); + // The setters for the variables + static Brew set_mode(Brew mode); private: - Caffeine() { - CUBLAS_CHECK(cublasCreate(&cublas_handle_)); - }; + Caffeine(); static shared_ptr singleton_; cublasHandle_t cublas_handle_; - public: - ~Caffeine() { - if (!cublas_handle_) { - CUBLAS_CHECK(cublasDestroy(cublas_handle_)); - } - } - static Caffeine& Get() { - if (!singleton_) { - singleton_.reset(new Caffeine()); - } - return *singleton_; - } - - static cublasHandle_t cublas_handle() { - return Get().cublas_handle_; - } + Brew mode_; }; } - #endif // CAFFEINE_COMMON_HPP_ diff --git a/src/caffeine/neuron_layer.cpp b/src/caffeine/neuron_layer.cpp index 35e975a..20745b0 100644 --- a/src/caffeine/neuron_layer.cpp +++ b/src/caffeine/neuron_layer.cpp @@ -1,6 +1,6 @@ -#include "caffeine/base.h" +#include "caffeine/base.hpp" namespace caffeine { -} // namespace caffeine \ No newline at end of file +} // namespace caffeine