Skip to content

Commit

Permalink
remove boost dependecies
Browse files Browse the repository at this point in the history
(refer to BVLC#2537)
  • Loading branch information
sh1r0 committed Jun 12, 2015
1 parent 8c31ef1 commit ac93b5d
Show file tree
Hide file tree
Showing 12 changed files with 911 additions and 309 deletions.
5 changes: 3 additions & 2 deletions Makefile.mobile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ src/caffe/layers/mvn_layer.cpp \
src/caffe/layers/neuron_layer.cpp \
src/caffe/layers/pooling_layer.cpp \
src/caffe/layers/power_layer.cpp \
src/caffe/layers/prelu_layer.cpp \
src/caffe/layers/relu_layer.cpp \
src/caffe/layers/sigmoid_cross_entropy_loss_layer.cpp \
src/caffe/layers/sigmoid_layer.cpp \
Expand Down Expand Up @@ -94,8 +95,8 @@ OBJS := $(PROTO_OBJS) $(CXX_OBJS)
COMMON_FLAGS += -DCPU_ONLY

INCLUDE_DIRS += ./include ./include/caffe/proto
LIBRARIES:=protobuf opencv_core opencv_highgui opencv_imgproc boost_thread boost_system boost_date_time
LIBRARY_DIRS:=/usr/local/lib
LIBRARIES := protobuf opencv_core opencv_highgui opencv_imgproc
LIBRARY_DIRS := /usr/local/lib

ifeq ($(USE_EIGEN), y)
COMMON_FLAGS += -DUSE_EIGEN
Expand Down
9 changes: 5 additions & 4 deletions include/caffe/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "caffe/glog_alternate.hpp"

#include <unistd.h>
#include <memory>
#include <climits>
#include <cmath>
Expand Down Expand Up @@ -61,7 +62,6 @@ namespace cv { class Mat; }
namespace caffe {

// Common functions and classes from std that caffe often uses.
using std::shared_ptr;
using std::fstream;
using std::ios;
using std::isnan;
Expand All @@ -72,6 +72,7 @@ using std::map;
using std::ostringstream;
using std::pair;
using std::set;
using std::shared_ptr;
using std::string;
using std::stringstream;
using std::vector;
Expand All @@ -93,7 +94,7 @@ class Caffe {
}
enum Brew { CPU, GPU };

// This random number generator facade hides boost and CUDA rng
// This random number generator facade hides std and CUDA rng
// implementation from one another (for cross-platform compatibility).
class RNG {
public:
Expand All @@ -107,7 +108,7 @@ class Caffe {
shared_ptr<Generator> generator_;
};

// Getters for boost rng, curand, and cublas handles
// Getters for std rng, curand, and cublas handles
inline static RNG& rng_stream() {
if (!Get().random_generator_) {
Get().random_generator_.reset(new RNG());
Expand All @@ -129,7 +130,7 @@ class Caffe {
// freed in a non-pinned way, which may cause problems - I haven't verified
// it personally but better to note it here in the header file.
inline static void set_mode(Brew mode) { Get().mode_ = mode; }
// Sets the random seed of both boost and curand
// Sets the random seed of both std and curand
static void set_random_seed(const unsigned int seed);
// Sets the device. Since we have cublas and curand stuff, set device also
// requires us to reset those values.
Expand Down
12 changes: 4 additions & 8 deletions include/caffe/internal_thread.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#ifndef CAFFE_INTERNAL_THREAD_HPP_
#define CAFFE_INTERNAL_THREAD_HPP_

#include "caffe/common.hpp"
#include <thread>

/**
Forward declare boost::thread instead of including boost/thread.hpp
to avoid a boost/NVCC issues (#1009, #1010) on OSX.
*/
namespace boost { class thread; }
#include "caffe/common.hpp"

namespace caffe {

/**
* Virtual class encapsulate boost::thread for use in base class
* Virtual class encapsulate std::thread for use in base class
* The child class will acquire the ability to run a single thread,
* by reimplementing the virutal function InternalThreadEntry.
*/
Expand All @@ -34,7 +30,7 @@ class InternalThread {
with the code you want your thread to run. */
virtual void InternalThreadEntry() {}

shared_ptr<boost::thread> thread_;
shared_ptr<std::thread> thread_;
};

} // namespace caffe
Expand Down
Loading

0 comments on commit ac93b5d

Please sign in to comment.