summaryrefslogtreecommitdiff
path: root/src/caffe/layer.cpp
diff options
context:
space:
mode:
authorRonghang Hu <huronghang@hotmail.com>2015-08-12 12:05:56 -0700
committerRonghang Hu <huronghang@hotmail.com>2015-08-12 14:46:32 -0700
commit6b50ed6fc1897ce1ccd673cf0287788b38b58a6d (patch)
tree71217c1e2b3f75c5774db1b0e0afb9ac0d040b2d /src/caffe/layer.cpp
parent0d34d5ba0fbdc09ac8f372cb581ccaec599f10bc (diff)
downloadcaffeonacl-6b50ed6fc1897ce1ccd673cf0287788b38b58a6d.tar.gz
caffeonacl-6b50ed6fc1897ce1ccd673cf0287788b38b58a6d.tar.bz2
caffeonacl-6b50ed6fc1897ce1ccd673cf0287788b38b58a6d.zip
Apply mutex only to shared layers and fix NVCC warning
Diffstat (limited to 'src/caffe/layer.cpp')
-rw-r--r--src/caffe/layer.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/caffe/layer.cpp b/src/caffe/layer.cpp
new file mode 100644
index 00000000..3b912898
--- /dev/null
+++ b/src/caffe/layer.cpp
@@ -0,0 +1,27 @@
+#include <boost/thread.hpp>
+#include "caffe/layer.hpp"
+
+namespace caffe {
+
+template <typename Dtype>
+void Layer<Dtype>::InitMutex() {
+ forward_mutex_.reset(new boost::mutex());
+}
+
+template <typename Dtype>
+void Layer<Dtype>::Lock() {
+ if (IsShared()) {
+ forward_mutex_->lock();
+ }
+}
+
+template <typename Dtype>
+void Layer<Dtype>::Unlock() {
+ if (IsShared()) {
+ forward_mutex_->unlock();
+ }
+}
+
+INSTANTIATE_CLASS(Layer);
+
+} // namespace caffe