Skip to content

Commit

Permalink
make android build again
Browse files Browse the repository at this point in the history
  • Loading branch information
Yangqing committed Aug 10, 2016
1 parent 9c459be commit 1fc9830
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 31 deletions.
1 change: 1 addition & 0 deletions build_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Config.USE_LITE_PROTO = False
Config.USE_SYSTEM_EIGEN = False
Config.USE_GLOG = False
Config.USE_GFLAGS = False
Config.USE_RTTI = False
Config.USE_OPENMP = False
Config.CUDA_DIR = "non-existing"
Expand Down
20 changes: 0 additions & 20 deletions caffe2/core/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ class EnforceNotMet : public std::exception {
vector<string> msg_stack_;
};

// Exception handling: if we are enabling exceptions, we will turn on the caffe
// enforce capabilities. If one does not allow exceptions during compilation
// time, we will simply do LOG(FATAL).
#ifdef __EXCEPTIONS

#define CAFFE_ENFORCE(condition, ...) \
do { \
if (!(condition)) { \
Expand All @@ -109,21 +104,6 @@ class EnforceNotMet : public std::exception {
throw ::caffe2::EnforceNotMet( \
__FILE__, __LINE__, "", ::caffe2::MakeString(__VA_ARGS__))

#else // __EXCEPTIONS

#define CAFFE_ENFORCE(condition, ...) \
CHECK(condition) << "[exception as fatal] " \
<< ::caffe2::MakeString(__VA_ARGS__)

#define CAFFE_THROW(...) \
LOG(FATAL) << "[exception as fatal] " << ::caffe2::MakeString(__VA_ARGS__);

#endif // __EXCEPTIONS

#define CAFFE_FAIL(...) \
static_assert( \
false, "CAFFE_FAIL is renamed CAFFE_THROW. Kindly change your code.")

} // namespace caffe2

#endif // CAFFE2_CORE_LOGGING_H_
11 changes: 11 additions & 0 deletions caffe2/core/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,17 @@ class Tensor {
return size_ != old_size;
}

bool SetDims(const vector<long int>& src) {
auto old_size = size_;
dims_.resize(src.size());
size_ = 1;
for (int i = 0; i < src.size(); ++i) {
size_ *= src[i];
dims_[i] = src[i];
}
return size_ != old_size;
}

bool SetDims(const vector<int>& src) {
auto old_size = size_;
dims_.resize(src.size());
Expand Down
4 changes: 2 additions & 2 deletions caffe2/core/typeid.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ std::map<CaffeTypeId, string>& gTypeNames() {
return g_type_names;
}

std::unordered_set<string>& gRegisteredTypeNames() {
static std::unordered_set<string> g_registered_type_names;
std::set<string>& gRegisteredTypeNames() {
static std::set<string> g_registered_type_names;
return g_registered_type_names;
}

Expand Down
10 changes: 2 additions & 8 deletions caffe2/core/typeid.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
#include <map>
#include <type_traits>
#ifdef __GXX_RTTI
#include <set>
#include <typeinfo>
#include <unordered_set>
#endif

#ifdef __EXCEPTIONS
#include <exception>
#endif // __EXCEPTIONS

#include "caffe2/core/common.h"

Expand All @@ -23,7 +21,7 @@ namespace caffe2 {
typedef intptr_t CaffeTypeId;
std::map<CaffeTypeId, string>& gTypeNames();
#ifdef __GXX_RTTI
std::unordered_set<string>& gRegisteredTypeNames();
std::set<string>& gRegisteredTypeNames();
#endif // __GXX_RTTI

// A utility function to demangle a function name.
Expand All @@ -46,11 +44,7 @@ struct TypeNameRegisterer {
<< " registered twice. This should "
"not happen. Are you using RTLD_GLOBAL correctly?"
<< std::endl;
#ifdef __EXCEPTIONS
throw std::runtime_error("TypeNameRegisterer error with type " + name);
#else
exit(EXIT_FAILURE);
#endif // __EXCEPTIONS
}
gRegisteredTypeNames().insert(name);
#else // __GXX_RTTI
Expand Down
2 changes: 1 addition & 1 deletion caffe2/python/BREW
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ python_cc_extension(
python_cc_extension(
name="caffe2_pybind11",
srcs=[
"db.cc",
"pybind.cc",
],
deps=[
"//caffe2:core",
Expand Down

0 comments on commit 1fc9830

Please sign in to comment.