From 0522453820b362ebd00ca10e8ede9c95bcc94c06 Mon Sep 17 00:00:00 2001 From: Yangqing Jia Date: Fri, 13 Sep 2013 12:43:08 -0700 Subject: [PATCH] organization --- .gitignore | 3 +++ src/Makefile | 2 +- src/caffeine/_blob.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/caffeine/blob.hpp | 71 +++--------------------------------------------- 4 files changed, 80 insertions(+), 69 deletions(-) create mode 100644 src/caffeine/_blob.cpp diff --git a/.gitignore b/.gitignore index d0a02f2..664c63b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ # test files src/test_caffeine + +# vim swp files +*.swp diff --git a/src/Makefile b/src/Makefile index ec67810..b8c9dcc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -8,7 +8,7 @@ PROJECT := caffeine NAME := lib$(PROJECT).so TEST_NAME := test_$(PROJECT) -CXX_SRCS := $(shell find caffeine ! -name "test_*.cpp" -name "*.cpp") +CXX_SRCS := $(shell find caffeine ! -name "test_*.cpp" ! -name "_*.cpp" -name "*.cpp") TEST_SRCS := $(shell find caffeine -name "test_*.cpp") gtest/gtest-all.cpp PROTO_SRCS := $(wildcard caffeine/proto/*.proto) PROTO_GEN_HEADER := ${PROTO_SRCS:.proto=.pb.h} diff --git a/src/caffeine/_blob.cpp b/src/caffeine/_blob.cpp new file mode 100644 index 0000000..8eb95ab --- /dev/null +++ b/src/caffeine/_blob.cpp @@ -0,0 +1,73 @@ +#include "caffeine/blob.hpp" +#include "caffeine/common.hpp" +#include "caffeine/syncedmem.hpp" + +namespace caffeine { + +template +void Blob::Reshape(const int num, const int channels, const int height, + const int width) { + num_ = num; + channels_ = channels; + height_ = height; + width_ = width; + count_ = num_ * channels_ * height_ * width_; + data_.reset(new SyncedMemory(count_ * sizeof(Dtype))); + diff_.reset(new SyncedMemory(count_ * sizeof(Dtype))); +} + +template +const Dtype* Blob::cpu_data() { + check_data(); + return data_->cpu_data(); +} + +template +const Dtype* Blob::gpu_data() { + check_data(); + return data_->gpu_data(); +} + +template +const Dtype* Blob::cpu_diff() { + check_diff(); + return diff_->cpu_data(); +} + +template +const Dtype* Blob::gpu_diff() { + check_diff(); + return diff_->gpu_data(); +} + +template +Dtype* Blob::mutable_cpu_data() { + check_data(); + return data_->mutable_cpu_data(); +} + +template +Dtype* Blob::mutable_gpu_data() { + check_data(); + return data_->mutable_gpu_data(); +} + +template +Dtype* Blob::mutable_cpu_diff() { + check_diff(); + return diff_->mutable_cpu_data(); +} + +template +Dtype* Blob::mutable_gpu_diff() { + check_diff(); + return diff_->mutable_gpu_data(); +} + +template +void Blob::update() { + +} + +} // namespace caffeine + diff --git a/src/caffeine/blob.hpp b/src/caffeine/blob.hpp index eb2f2cb..a2e3131 100644 --- a/src/caffeine/blob.hpp +++ b/src/caffeine/blob.hpp @@ -1,8 +1,6 @@ #ifndef CAFFEINE_BLOB_HPP #define CAFFEINE_BLOB_HPP -#include - #include "caffeine/common.hpp" #include "caffeine/syncedmem.hpp" @@ -50,71 +48,8 @@ class Blob { int count_; }; // class Blob -template -void Blob::Reshape(const int num, const int channels, const int height, - const int width) { - num_ = num; - channels_ = channels; - height_ = height; - width_ = width; - count_ = num_ * channels_ * height_ * width_; - data_.reset(new SyncedMemory(count_ * sizeof(Dtype))); - diff_.reset(new SyncedMemory(count_ * sizeof(Dtype))); -} - -template -const Dtype* Blob::cpu_data() { - check_data(); - return data_->cpu_data(); -} - -template -const Dtype* Blob::gpu_data() { - check_data(); - return data_->gpu_data(); -} - -template -const Dtype* Blob::cpu_diff() { - check_diff(); - return diff_->cpu_data(); -} - -template -const Dtype* Blob::gpu_diff() { - check_diff(); - return diff_->gpu_data(); -} - -template -Dtype* Blob::mutable_cpu_data() { - check_data(); - return data_->mutable_cpu_data(); -} - -template -Dtype* Blob::mutable_gpu_data() { - check_data(); - return data_->mutable_gpu_data(); -} - -template -Dtype* Blob::mutable_cpu_diff() { - check_diff(); - return diff_->mutable_cpu_data(); -} - -template -Dtype* Blob::mutable_gpu_diff() { - check_diff(); - return diff_->mutable_gpu_data(); -} - -template -void Blob::update() { - -} - } // namespace caffeine -#endif // CAFFEINE_BLOB_HPP_ \ No newline at end of file +#include "caffeine/_blob.cpp" + +#endif // CAFFEINE_BLOB_HPP_ -- 2.7.4