1 #ifndef CAFFE2_CORE_LOGGING_IS_NOT_GOOGLE_GLOG_H_ 2 #define CAFFE2_CORE_LOGGING_IS_NOT_GOOGLE_GLOG_H_ 18 #if !defined(_MSC_VER) || !defined(ERROR) 25 const int WARNING = 1;
27 const char CAFFE2_SEVERITY_PREFIX[] =
"FEWIV";
35 std::stringstream &stream() {
return stream_; }
39 void DealWithFatal() { abort(); }
42 std::stringstream stream_;
54 void operator&(
const std::ostream &s) { }
59 void LogMessageFatal(
const char *file,
int line,
const T &message) {
66 T& CheckNotNullCommon(
const char *file,
int line,
const char *names, T& t) {
68 LogMessageFatal(file, line, std::string(names));
74 T* CheckNotNull(
const char *file,
int line,
const char *names, T* t) {
75 return CheckNotNullCommon(file, line, names, t);
79 T& CheckNotNull(
const char *file,
int line,
const char *names, T& t) {
80 return CheckNotNullCommon(file, line, names, t);
87 static_assert(CAFFE2_LOG_THRESHOLD <= FATAL,
88 "CAFFE2_LOG_THRESHOLD should at most be FATAL.");
92 if (n >= CAFFE2_LOG_THRESHOLD) \ 93 ::caffe2::MessageLogger((char*)__FILE__, __LINE__, n).stream() 94 #define VLOG(n) LOG((-n)) 96 #define LOG_IF(n, condition) \ 97 if (n >= CAFFE2_LOG_THRESHOLD && (condition)) \ 98 ::caffe2::MessageLogger((char*)__FILE__, __LINE__, n).stream() 99 #define VLOG_IF(n, condition) LOG_IF((-n), (condition)) 101 #define VLOG_IS_ON(verboselevel) (CAFFE2_LOG_THRESHOLD <= -(verboselevel)) 104 #define FATAL_IF(condition) \ 105 condition ? (void) 0 : ::caffe2::LoggerVoidify() & \ 106 ::caffe2::MessageLogger((char*)__FILE__, __LINE__, FATAL).stream() 109 #define CHECK(condition) FATAL_IF(condition) \ 110 << "Check failed: " #condition " " 114 #define DCHECK(condition) FATAL_IF(condition) \ 115 << "Check failed: " #condition " " 118 #define DCHECK(condition) if(false) CHECK(condition) 121 #define CHECK_OP(val1, val2, op) FATAL_IF((val1 op val2)) \ 122 << "Check failed: " #val1 " " #op " " #val2 " " 125 #define CHECK_EQ(val1, val2) CHECK_OP(val1, val2, ==) 126 #define CHECK_NE(val1, val2) CHECK_OP(val1, val2, !=) 127 #define CHECK_LE(val1, val2) CHECK_OP(val1, val2, <=) 128 #define CHECK_LT(val1, val2) CHECK_OP(val1, val2, <) 129 #define CHECK_GE(val1, val2) CHECK_OP(val1, val2, >=) 130 #define CHECK_GT(val1, val2) CHECK_OP(val1, val2, >) 134 #define DCHECK_EQ(val1, val2) CHECK_OP(val1, val2, ==) 135 #define DCHECK_NE(val1, val2) CHECK_OP(val1, val2, !=) 136 #define DCHECK_LE(val1, val2) CHECK_OP(val1, val2, <=) 137 #define DCHECK_LT(val1, val2) CHECK_OP(val1, val2, <) 138 #define DCHECK_GE(val1, val2) CHECK_OP(val1, val2, >=) 139 #define DCHECK_GT(val1, val2) CHECK_OP(val1, val2, >) 142 #define DCHECK_EQ(val1, val2) if(false) CHECK_OP(val1, val2, ==) 143 #define DCHECK_NE(val1, val2) if(false) CHECK_OP(val1, val2, !=) 144 #define DCHECK_LE(val1, val2) if(false) CHECK_OP(val1, val2, <=) 145 #define DCHECK_LT(val1, val2) if(false) CHECK_OP(val1, val2, <) 146 #define DCHECK_GE(val1, val2) if(false) CHECK_OP(val1, val2, >=) 147 #define DCHECK_GT(val1, val2) if(false) CHECK_OP(val1, val2, >) 151 #define CHECK_NOTNULL(val) \ 152 ::caffe2::CheckNotNull( \ 153 __FILE__, __LINE__, "Check failed: '" #val "' Must be non NULL", (val)) 157 #define DCHECK_NOTNULL(val) \ 158 ::caffe2::CheckNotNull( \ 159 __FILE__, __LINE__, "Check failed: '" #val "' Must be non NULL", (val)) 162 #define DCHECK_NOTNULL(val) if (false) CHECK_NOTNULL(val) 173 template<
class First,
class Second>
174 std::ostream& operator<<(
175 std::ostream& out,
const std::pair<First, Second>& p);
176 template <
class Iter>
177 void PrintSequence(std::ostream& ss, Iter begin, Iter end);
179 #define INSTANTIATE_FOR_CONTAINER(container) \ 180 template <class... Types> \ 181 std::ostream& operator<<( \ 182 std::ostream& out, const container<Types...>& seq) { \ 183 PrintSequence(out, seq.begin(), seq.end()); \ 187 INSTANTIATE_FOR_CONTAINER(std::vector)
188 INSTANTIATE_FOR_CONTAINER(std::map)
189 INSTANTIATE_FOR_CONTAINER(std::set)
190 #undef INSTANTIATE_FOR_CONTAINER 192 template<
class First,
class Second>
193 inline std::ostream& operator<<(
194 std::ostream& out,
const std::pair<First, Second>& p) {
195 out <<
'(' << p.first <<
", " << p.second <<
')';
199 template <
class Iter>
200 inline void PrintSequence(std::ostream& out, Iter begin, Iter end) {
202 for (
int i = 0; begin != end && i < 100; ++i, ++begin) {
203 if (i > 0) out <<
' ';
212 #endif // CAFFE2_CORE_LOGGING_IS_NOT_GOOGLE_GLOG_H_ A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Commandline flags support for Caffe2.