From 30a7caacf883d5b8be7306cd072c37104d202270 Mon Sep 17 00:00:00 2001 From: zhangjie Date: Sun, 11 Dec 2016 18:43:44 +0800 Subject: [PATCH] update --- 3rdparty/include/.gitignore | 1 - copydeps.bat | 6 ----- include/caffe/blob.hpp | 5 ---- include/caffe/common.hpp | 2 -- include/caffe/syncedmem.hpp | 19 ++++--------- src/caffe/blob.cpp | 53 ------------------------------------- src/caffe/syncedmem.cpp | 22 --------------- 7 files changed, 5 insertions(+), 103 deletions(-) diff --git a/3rdparty/include/.gitignore b/3rdparty/include/.gitignore index 42d3e6b..cfb4283 100644 --- a/3rdparty/include/.gitignore +++ b/3rdparty/include/.gitignore @@ -1,2 +1 @@ -glog/ google/ diff --git a/copydeps.bat b/copydeps.bat index 3ed456a..96cbeef 100644 --- a/copydeps.bat +++ b/copydeps.bat @@ -1,9 +1,3 @@ -mkdir 3rdparty\include\glog -copy 3rdparty\src\glog\src\windows\glog 3rdparty\include\glog -copy 3rdparty\src\glog\Debug\libglog.lib 3rdparty\lib\libglogd.lib -copy 3rdparty\src\glog\Release\libglog.lib 3rdparty\lib\libglog.lib -copy 3rdparty\src\glog\Release\libglog.dll 3rdparty\bin\libglog.dll - call 3rdparty\src\protobuf\cmake\build\extract_includes.bat move include\google 3rdparty\include\ copy 3rdparty\src\protobuf\cmake\build\Debug\libprotobuf.lib 3rdparty\lib\libprotobufd.lib diff --git a/include/caffe/blob.hpp b/include/caffe/blob.hpp index af360ac..8a7c7c4 100644 --- a/include/caffe/blob.hpp +++ b/include/caffe/blob.hpp @@ -218,14 +218,9 @@ class Blob { const Dtype* cpu_data() const; void set_cpu_data(Dtype* data); - const int* gpu_shape() const; - const Dtype* gpu_data() const; const Dtype* cpu_diff() const; - const Dtype* gpu_diff() const; Dtype* mutable_cpu_data(); - Dtype* mutable_gpu_data(); Dtype* mutable_cpu_diff(); - Dtype* mutable_gpu_diff(); void Update(); void FromProto(const BlobProto& proto, bool reshape = true); void ToProto(BlobProto* proto, bool write_diff = false) const; diff --git a/include/caffe/common.hpp b/include/caffe/common.hpp index 4e96417..8e1c236 100644 --- a/include/caffe/common.hpp +++ b/include/caffe/common.hpp @@ -15,8 +15,6 @@ #include "caffe/util/logging.hpp" -#define NO_GPU LOG(FATAL) << "Cannot use GPU in CPU-only Caffe: check mode." - // Convert macro to string #define STRINGIFY(m) #m #define AS_STRING(m) STRINGIFY(m) diff --git a/include/caffe/syncedmem.hpp b/include/caffe/syncedmem.hpp index a845b1f..4fb38cf 100644 --- a/include/caffe/syncedmem.hpp +++ b/include/caffe/syncedmem.hpp @@ -32,35 +32,26 @@ inline void CaffeFreeHost(void* ptr, bool use_cuda) { class SyncedMemory { public: SyncedMemory() - : cpu_ptr_(NULL), gpu_ptr_(NULL), size_(0), head_(UNINITIALIZED), - own_cpu_data_(false), cpu_malloc_use_cuda_(false), own_gpu_data_(false), - gpu_device_(-1) {} + : cpu_ptr_(NULL), size_(0), head_(UNINITIALIZED), + own_cpu_data_(false) {} explicit SyncedMemory(size_t size) - : cpu_ptr_(NULL), gpu_ptr_(NULL), size_(size), head_(UNINITIALIZED), - own_cpu_data_(false), cpu_malloc_use_cuda_(false), own_gpu_data_(false), - gpu_device_(-1) {} + : cpu_ptr_(NULL), size_(size), head_(UNINITIALIZED), + own_cpu_data_(false) {} ~SyncedMemory(); const void* cpu_data(); void set_cpu_data(void* data); - const void* gpu_data(); - void set_gpu_data(void* data); void* mutable_cpu_data(); - void* mutable_gpu_data(); - enum SyncedHead { UNINITIALIZED, HEAD_AT_CPU, HEAD_AT_GPU, SYNCED }; + enum SyncedHead { UNINITIALIZED, HEAD_AT_CPU }; SyncedHead head() { return head_; } size_t size() { return size_; } private: void to_cpu(); - void to_gpu(); void* cpu_ptr_; - void* gpu_ptr_; size_t size_; SyncedHead head_; bool own_cpu_data_; bool cpu_malloc_use_cuda_; - bool own_gpu_data_; - int gpu_device_; DISABLE_COPY_AND_ASSIGN(SyncedMemory); }; // class SyncedMemory diff --git a/src/caffe/blob.cpp b/src/caffe/blob.cpp index 3c82ce7..addffdf 100644 --- a/src/caffe/blob.cpp +++ b/src/caffe/blob.cpp @@ -74,12 +74,6 @@ Blob::Blob(const vector& shape) Reshape(shape); } -template -const int* Blob::gpu_shape() const { - CHECK(shape_data_); - return (const int*)shape_data_->gpu_data(); -} - template const Dtype* Blob::cpu_data() const { CHECK(data_); @@ -92,48 +86,24 @@ void Blob::set_cpu_data(Dtype* data) { data_->set_cpu_data(data); } -template -const Dtype* Blob::gpu_data() const { - CHECK(data_); - return (const Dtype*)data_->gpu_data(); -} - template const Dtype* Blob::cpu_diff() const { CHECK(diff_); return (const Dtype*)diff_->cpu_data(); } -template -const Dtype* Blob::gpu_diff() const { - CHECK(diff_); - return (const Dtype*)diff_->gpu_data(); -} - template Dtype* Blob::mutable_cpu_data() { CHECK(data_); return static_cast(data_->mutable_cpu_data()); } -template -Dtype* Blob::mutable_gpu_data() { - CHECK(data_); - return static_cast(data_->mutable_gpu_data()); -} - template Dtype* Blob::mutable_cpu_diff() { CHECK(diff_); return static_cast(diff_->mutable_cpu_data()); } -template -Dtype* Blob::mutable_gpu_diff() { - CHECK(diff_); - return static_cast(diff_->mutable_gpu_data()); -} - template void Blob::ShareData(const Blob& other) { CHECK_EQ(count_, other.count()); @@ -162,10 +132,6 @@ void Blob::Update() { static_cast(diff_->cpu_data()), static_cast(data_->mutable_cpu_data())); break; - case SyncedMemory::HEAD_AT_GPU: - case SyncedMemory::SYNCED: - NO_GPU; - break; default: LOG(FATAL) << "Syncedmem not initialized."; } @@ -187,9 +153,6 @@ Dtype Blob::asum_data() const { switch (data_->head()) { case SyncedMemory::HEAD_AT_CPU: return caffe_cpu_asum(count_, cpu_data()); - case SyncedMemory::HEAD_AT_GPU: - case SyncedMemory::SYNCED: - NO_GPU; case SyncedMemory::UNINITIALIZED: return 0; default: @@ -214,9 +177,6 @@ Dtype Blob::asum_diff() const { switch (diff_->head()) { case SyncedMemory::HEAD_AT_CPU: return caffe_cpu_asum(count_, cpu_diff()); - case SyncedMemory::HEAD_AT_GPU: - case SyncedMemory::SYNCED: - NO_GPU; case SyncedMemory::UNINITIALIZED: return 0; default: @@ -245,10 +205,6 @@ Dtype Blob::sumsq_data() const { data = cpu_data(); sumsq = caffe_cpu_dot(count_, data, data); break; - case SyncedMemory::HEAD_AT_GPU: - case SyncedMemory::SYNCED: - NO_GPU; - break; case SyncedMemory::UNINITIALIZED: return 0; default: @@ -277,9 +233,6 @@ Dtype Blob::sumsq_diff() const { diff = cpu_diff(); sumsq = caffe_cpu_dot(count_, diff, diff); break; - case SyncedMemory::HEAD_AT_GPU: - case SyncedMemory::SYNCED: - NO_GPU; case SyncedMemory::UNINITIALIZED: return 0; default: @@ -305,9 +258,6 @@ void Blob::scale_data(Dtype scale_factor) { data = mutable_cpu_data(); caffe_scal(count_, scale_factor, data); return; - case SyncedMemory::HEAD_AT_GPU: - case SyncedMemory::SYNCED: - NO_GPU; case SyncedMemory::UNINITIALIZED: return; default: @@ -332,9 +282,6 @@ void Blob::scale_diff(Dtype scale_factor) { diff = mutable_cpu_diff(); caffe_scal(count_, scale_factor, diff); return; - case SyncedMemory::HEAD_AT_GPU: - case SyncedMemory::SYNCED: - NO_GPU; case SyncedMemory::UNINITIALIZED: return; default: diff --git a/src/caffe/syncedmem.cpp b/src/caffe/syncedmem.cpp index 3fbf7df..786a7c5 100644 --- a/src/caffe/syncedmem.cpp +++ b/src/caffe/syncedmem.cpp @@ -18,19 +18,11 @@ inline void SyncedMemory::to_cpu() { head_ = HEAD_AT_CPU; own_cpu_data_ = true; break; - case HEAD_AT_GPU: - NO_GPU; - break; case HEAD_AT_CPU: - case SYNCED: break; } } -inline void SyncedMemory::to_gpu() { - NO_GPU; -} - const void* SyncedMemory::cpu_data() { to_cpu(); return (const void*)cpu_ptr_; @@ -46,25 +38,11 @@ void SyncedMemory::set_cpu_data(void* data) { own_cpu_data_ = false; } -const void* SyncedMemory::gpu_data() { - NO_GPU; - return NULL; -} - -void SyncedMemory::set_gpu_data(void* data) { - NO_GPU; -} - void* SyncedMemory::mutable_cpu_data() { to_cpu(); head_ = HEAD_AT_CPU; return cpu_ptr_; } -void* SyncedMemory::mutable_gpu_data() { - NO_GPU; - return NULL; -} - } // namespace caffe