From 1fc9830b596c4223188f137e1d63a4b7eb4ed0e5 Mon Sep 17 00:00:00 2001 From: Yangqing Jia Date: Wed, 10 Aug 2016 14:00:11 -0700 Subject: [PATCH] make android build again --- build_android.py | 1 + caffe2/core/logging.h | 20 -------------------- caffe2/core/tensor.h | 11 +++++++++++ caffe2/core/typeid.cc | 4 ++-- caffe2/core/typeid.h | 10 ++-------- caffe2/python/BREW | 2 +- 6 files changed, 17 insertions(+), 31 deletions(-) diff --git a/build_android.py b/build_android.py index 4761f69bb4655..5a71846023250 100644 --- a/build_android.py +++ b/build_android.py @@ -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" diff --git a/caffe2/core/logging.h b/caffe2/core/logging.h index 6f4d1ce464b0e..d617e9a672211 100644 --- a/caffe2/core/logging.h +++ b/caffe2/core/logging.h @@ -92,11 +92,6 @@ class EnforceNotMet : public std::exception { vector 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)) { \ @@ -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_ diff --git a/caffe2/core/tensor.h b/caffe2/core/tensor.h index 4606cd3aee833..e2006f960f600 100644 --- a/caffe2/core/tensor.h +++ b/caffe2/core/tensor.h @@ -535,6 +535,17 @@ class Tensor { return size_ != old_size; } + bool SetDims(const vector& 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& src) { auto old_size = size_; dims_.resize(src.size()); diff --git a/caffe2/core/typeid.cc b/caffe2/core/typeid.cc index da4e875d3e1c7..5b6352b8ca112 100644 --- a/caffe2/core/typeid.cc +++ b/caffe2/core/typeid.cc @@ -9,8 +9,8 @@ std::map& gTypeNames() { return g_type_names; } -std::unordered_set& gRegisteredTypeNames() { - static std::unordered_set g_registered_type_names; +std::set& gRegisteredTypeNames() { + static std::set g_registered_type_names; return g_registered_type_names; } diff --git a/caffe2/core/typeid.h b/caffe2/core/typeid.h index d3fdc9964725a..c737b419e9ff3 100644 --- a/caffe2/core/typeid.h +++ b/caffe2/core/typeid.h @@ -8,13 +8,11 @@ #include #include #ifdef __GXX_RTTI +#include #include -#include #endif -#ifdef __EXCEPTIONS #include -#endif // __EXCEPTIONS #include "caffe2/core/common.h" @@ -23,7 +21,7 @@ namespace caffe2 { typedef intptr_t CaffeTypeId; std::map& gTypeNames(); #ifdef __GXX_RTTI -std::unordered_set& gRegisteredTypeNames(); +std::set& gRegisteredTypeNames(); #endif // __GXX_RTTI // A utility function to demangle a function name. @@ -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 diff --git a/caffe2/python/BREW b/caffe2/python/BREW index 0f0afd6c8fa9e..c0eefc2b9aa7f 100644 --- a/caffe2/python/BREW +++ b/caffe2/python/BREW @@ -26,7 +26,7 @@ python_cc_extension( python_cc_extension( name="caffe2_pybind11", srcs=[ - "db.cc", + "pybind.cc", ], deps=[ "//caffe2:core",