Skip to content

Commit

Permalink
Add synced_version file, re-diff HEAD to synced_version.
Browse files Browse the repository at this point in the history
  • Loading branch information
solrex committed Feb 4, 2017
1 parent 771b58c commit f4e4284
Show file tree
Hide file tree
Showing 19 changed files with 400 additions and 192 deletions.
8 changes: 4 additions & 4 deletions patch/include/caffe/caffe.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
--- caffe/include/caffe/caffe.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/caffe.hpp 2017-01-31 22:54:21.000000000 +0800
--- caffe/include/caffe/caffe.hpp 2017-01-27 09:51:55.335623700 +0800
+++ ../include/caffe/caffe.hpp 2017-02-04 22:35:34.594153197 +0800
@@ -10,10 +10,14 @@
#include "caffe/layer.hpp"
#include "caffe/layer_factory.hpp"
#include "caffe/net.hpp"
+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
#include "caffe/parallel.hpp"
+#endif
#include "caffe/proto/caffe.pb.h"
+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
#include "caffe/solver.hpp"
#include "caffe/solver_factory.hpp"
+#endif
Expand Down
26 changes: 14 additions & 12 deletions patch/include/caffe/common.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
--- caffe/include/caffe/common.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/common.hpp 2017-01-31 23:45:15.000000000 +0800
@@ -1,9 +1,17 @@
--- caffe/include/caffe/common.hpp 2017-01-27 09:51:55.340623900 +0800
+++ ../include/caffe/common.hpp 2017-02-04 22:42:22.849568507 +0800
@@ -1,9 +1,19 @@
#ifndef CAFFE_COMMON_HPP_
#define CAFFE_COMMON_HPP_

+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
#include <boost/shared_ptr.hpp>
+#else
+#include <memory>
+#endif
+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
#include <gflags/gflags.h>
+#endif
+#ifndef DISABLE_GLOG
+#ifdef USE_GLOG
#include <glog/logging.h>
+#else
+#include "caffe/glog_wrapper.hpp"
+#endif

#include <climits>
#include <cmath>
@@ -22,6 +30,7 @@
@@ -22,6 +32,7 @@
#define STRINGIFY(m) #m
#define AS_STRING(m) STRINGIFY(m)

+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
// gflags 2.1 issue: namespace google was changed to gflags without warning.
// Luckily we will be able to use GFLAGS_GFLAGS_H_ to detect if it is version
// 2.1. If yes, we will add a temporary solution to redirect the namespace.
@@ -30,6 +39,7 @@
@@ -30,6 +41,7 @@
#ifndef GFLAGS_GFLAGS_H_
namespace gflags = google;
#endif // GFLAGS_GFLAGS_H_
+#endif // DISABLE_GFLAGS
+#endif // NO_CAFFE_MOBILE

// Disable the copy and assignment operator for a class.
#define DISABLE_COPY_AND_ASSIGN(classname) \
@@ -74,9 +84,13 @@
@@ -74,9 +86,13 @@

namespace caffe {

+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
// We will use the boost shared_ptr instead of the new C++11 one mainly
// because cuda does not work (at least now) well with C++11 features.
using boost::shared_ptr;
Expand Down
37 changes: 30 additions & 7 deletions patch/include/caffe/filler.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
--- caffe/include/caffe/filler.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/filler.hpp 2017-01-30 15:43:29.000000000 +0800
--- caffe/include/caffe/filler.hpp 2017-01-27 09:51:55.350123200 +0800
+++ ../include/caffe/filler.hpp 2017-02-04 22:35:34.594153197 +0800
@@ -45,6 +45,7 @@
}
};

+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
/// @brief Fills a Blob with uniformly distributed values @f$ x\sim U(a, b) @f$.
template <typename Dtype>
class UniformFiller : public Filler<Dtype> {
@@ -260,6 +261,7 @@
@@ -123,6 +124,7 @@
<< "Sparsity not supported by this Filler.";
}
};
+#endif

/**
* @brief Fills a Blob with values @f$ x \sim U(-a, +a) @f$ where @f$ a @f$ is
@@ -165,6 +167,7 @@
}
};

+#ifdef NO_CAFFE_MOBILE
/**
* @brief Fills a Blob with values @f$ x \sim N(0, \sigma^2) @f$ where
* @f$ \sigma^2 @f$ is set inversely proportional to number of incoming
@@ -260,6 +263,7 @@
<< "Sparsity not supported by this Filler.";
}
};
+#endif

/**
* @brief Get a specific filler from the specification given in FillerParameter.
@@ -272,6 +274,7 @@
@@ -272,18 +276,22 @@
const std::string& type = param.type();
if (type == "constant") {
return new ConstantFiller<Dtype>(param);
+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
} else if (type == "gaussian") {
return new GaussianFiller<Dtype>(param);
} else if (type == "positive_unitball") {
@@ -284,6 +287,7 @@
return new PositiveUnitballFiller<Dtype>(param);
} else if (type == "uniform") {
return new UniformFiller<Dtype>(param);
+#endif
} else if (type == "xavier") {
return new XavierFiller<Dtype>(param);
+#ifdef NO_CAFFE_MOBILE
} else if (type == "msra") {
return new MSRAFiller<Dtype>(param);
} else if (type == "bilinear") {
return new BilinearFiller<Dtype>(param);
Expand Down
10 changes: 5 additions & 5 deletions patch/include/caffe/layers/base_data_layer.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--- caffe/include/caffe/layers/base_data_layer.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/layers/base_data_layer.hpp 2017-01-30 15:43:29.000000000 +0800
--- caffe/include/caffe/layers/base_data_layer.hpp 2017-01-27 09:51:55.386123700 +0800
+++ ../include/caffe/layers/base_data_layer.hpp 2017-02-04 22:35:34.594153197 +0800
@@ -5,7 +5,9 @@

#include "caffe/blob.hpp"
#include "caffe/data_transformer.hpp"
+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
#include "caffe/internal_thread.hpp"
+#endif
#include "caffe/layer.hpp"
Expand All @@ -14,7 +14,7 @@
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) {}

protected:
+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
TransformationParameter transform_param_;
shared_ptr<DataTransformer<Dtype> > data_transformer_;
+#endif
Expand All @@ -25,7 +25,7 @@
Blob<Dtype> data_, label_;
};

+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
template <typename Dtype>
class BasePrefetchingDataLayer :
public BaseDataLayer<Dtype>, public InternalThread {
Expand Down
38 changes: 35 additions & 3 deletions patch/include/caffe/net.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
--- caffe/include/caffe/net.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/net.hpp 2017-01-30 15:43:29.000000000 +0800
--- caffe/include/caffe/net.hpp 2017-01-27 09:51:55.678623300 +0800
+++ ../include/caffe/net.hpp 2017-02-04 22:35:34.598149613 +0800
@@ -38,8 +38,10 @@
const vector<Blob<Dtype>*>& Forward(Dtype* loss = NULL);
/// @brief DEPRECATED; use Forward() instead.
const vector<Blob<Dtype>*>& ForwardPrefilled(Dtype* loss = NULL) {
+#ifndef DISABLE_GLOG
+#ifdef USE_GLOG
LOG_EVERY_N(WARNING, 1000) << "DEPRECATED: ForwardPrefilled() "
<< "will be removed in a future version. Use Forward().";
+#endif
return Forward(loss);
}

@@ -64,6 +66,7 @@
*/
void ClearParamDiffs();

+#ifdef ENABLE_BACKWARD
/**
* The network backward should take no input and output, since it solely
* computes the gradient w.r.t the parameters, and the data has already been
@@ -73,6 +76,7 @@
void BackwardFromTo(int start, int end);
void BackwardFrom(int start);
void BackwardTo(int end);
+#endif

/**
* @brief Reshape all layers from bottom to top.
@@ -82,6 +86,7 @@
*/
void Reshape();

+#ifdef ENABLE_BACKWARD
Dtype ForwardBackward() {
Dtype loss;
Forward(&loss);
@@ -91,6 +96,7 @@

/// @brief Updates the network weights based on the diff values computed.
void Update();
+#endif
/**
* @brief Shares weight data of owner blobs with shared blobs.
*
8 changes: 4 additions & 4 deletions patch/include/caffe/util/benchmark.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--- caffe/include/caffe/util/benchmark.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/util/benchmark.hpp 2017-01-31 22:38:20.000000000 +0800
--- caffe/include/caffe/util/benchmark.hpp 2017-01-27 09:51:55.716623000 +0800
+++ ../include/caffe/util/benchmark.hpp 2017-02-04 22:35:34.598149613 +0800
@@ -1,7 +1,11 @@
#ifndef CAFFE_UTIL_BENCHMARK_H_
#define CAFFE_UTIL_BENCHMARK_H_

+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
#include <boost/date_time/posix_time/posix_time.hpp>
+#else
+#include <sys/time.h>
Expand All @@ -16,7 +16,7 @@
cudaEvent_t start_gpu_;
cudaEvent_t stop_gpu_;
#endif
+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
boost::posix_time::ptime start_cpu_;
boost::posix_time::ptime stop_cpu_;
+#else
Expand Down
23 changes: 4 additions & 19 deletions patch/include/caffe/util/io.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
--- caffe/include/caffe/util/io.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/util/io.hpp 2017-01-30 15:43:29.000000000 +0800
--- caffe/include/caffe/util/io.hpp 2017-01-27 09:51:55.768122600 +0800
+++ ../include/caffe/util/io.hpp 2017-02-04 22:35:34.598149613 +0800
@@ -1,7 +1,9 @@
#ifndef CAFFE_UTIL_IO_H_
#define CAFFE_UTIL_IO_H_

+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
#include <boost/filesystem.hpp>
+#endif
#include <iomanip>
Expand All @@ -14,7 +14,7 @@
namespace caffe {

using ::google::protobuf::Message;
+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
using ::boost::filesystem::path;

inline void MakeTempDir(string* temp_dirname) {
Expand All @@ -26,18 +26,3 @@

bool ReadProtoFromTextFile(const char* filename, Message* proto);

@@ -129,6 +133,14 @@
bool DecodeDatumNative(Datum* datum);
bool DecodeDatum(Datum* datum, bool is_color);

+#ifdef CAFFE_COMPACT
+void ReadNetParamsFromTextFileOrDie(const string& param_file,
+ NetParameter* param);
+
+void ReadNetParamsFromBinaryFileOrDie(const string& param_file,
+ NetParameter* param);
+#endif
+
#ifdef USE_OPENCV
cv::Mat ReadImageToCVMat(const string& filename,
const int height, const int width, const bool is_color);
11 changes: 7 additions & 4 deletions patch/include/caffe/util/math_functions.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
--- caffe/include/caffe/util/math_functions.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/util/math_functions.hpp 2017-01-30 15:43:29.000000000 +0800
@@ -4,7 +4,9 @@
--- caffe/include/caffe/util/math_functions.hpp 2017-01-27 09:51:55.772623200 +0800
+++ ../include/caffe/util/math_functions.hpp 2017-02-04 22:45:32.054023741 +0800
@@ -4,7 +4,12 @@
#include <stdint.h>
#include <cmath> // for std::fabs and std::signbit

+#ifndef DISABLE_GLOG
+#ifdef USE_GLOG
#include "glog/logging.h"
+#endif
+#ifndef NO_CAFFE_MOBILE
+#include <string.h>
+#endif

#include "caffe/common.hpp"
Expand Down
28 changes: 14 additions & 14 deletions patch/include/caffe/util/rng.hpp.patch
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
--- caffe/include/caffe/util/rng.hpp 2017-01-31 23:29:02.000000000 +0800
+++ ../include/caffe/util/rng.hpp 2017-01-30 15:43:29.000000000 +0800
@@ -4,23 +4,31 @@
--- caffe/include/caffe/util/rng.hpp 2017-01-27 09:51:55.785123500 +0800
+++ ../include/caffe/util/rng.hpp 2017-02-04 22:35:34.598149613 +0800
@@ -4,14 +4,23 @@
#include <algorithm>
#include <iterator>

+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
+#FIXME extract random generator from boost
#include "boost/random/mersenne_twister.hpp"
#include "boost/random/uniform_int.hpp"
+#else
+#include <random>
+#endif

#include "caffe/common.hpp"

namespace caffe {

+#ifndef DISABLE_BOOST
+#ifdef USE_BOOST
typedef boost::mt19937 rng_t;

inline rng_t* caffe_rng() {
return static_cast<caffe::rng_t*>(Caffe::rng_stream().generator());
}
+#else
+typedef int rng_t;
+typedef std::mt19937 rng_t;
+#endif

// Fisher–Yates algorithm
inline rng_t* caffe_rng() {
return static_cast<caffe::rng_t*>(Caffe::rng_stream().generator());
@@ -21,6 +30,7 @@
template <class RandomAccessIterator, class RandomGenerator>
inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end,
RandomGenerator* gen) {
+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type
difference_type;
typedef typename boost::uniform_int<difference_type> dist_type;
@@ -32,11 +40,18 @@
@@ -32,11 +42,18 @@
dist_type dist(0, i);
std::iter_swap(begin + i, begin + dist(*gen));
}
Expand All @@ -43,7 +43,7 @@

template <class RandomAccessIterator>
inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end) {
+#ifndef CAFFE_COMPACT
+#ifdef NO_CAFFE_MOBILE
shuffle(begin, end, caffe_rng());
+#else
+ NOT_IMPLEMENTED;
Expand Down
Loading

0 comments on commit f4e4284

Please sign in to comment.