diff --git a/src/caffeine/base.h b/src/caffeine/base.h deleted file mode 100644 index c1fa8b1a..00000000 --- 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 38e6fd1b..1aad02af 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 35e975a4..20745b0f 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