Caffe2 - C++ API
A deep learning, cross platform ML framework
logging_is_google_glog.h
1 #ifndef C10_UTIL_LOGGING_IS_GOOGLE_GLOG_H_
2 #define C10_UTIL_LOGGING_IS_GOOGLE_GLOG_H_
3 
4 #include <map>
5 #include <set>
6 #include <vector>
7 
8 #include <iomanip> // because some of the caffe2 code uses e.g. std::setw
9 // Using google glog. For glog 0.3.2 versions, stl_logging.h needs to be before
10 // logging.h to actually use stl_logging. Because template magic.
11 // In addition, we do not do stl logging in .cu files because nvcc does not like
12 // it. Some mobile platforms do not like stl_logging, so we add an
13 // overload in that case as well.
14 
15 #ifdef __CUDACC__
16 #include <cuda.h>
17 #endif
18 
19 #if !defined(__CUDACC__) && !defined(C10_USE_MINIMAL_GLOG)
20 #include <glog/stl_logging.h>
21 
22 // Old versions of glog don't declare this using declaration, so help
23 // them out. Fortunately, C++ won't complain if you declare the same
24 // using declaration multiple times.
25 namespace std {
26 using ::operator<<;
27 }
28 
29 #else // !defined(__CUDACC__) && !defined(C10_USE_MINIMAL_GLOG)
30 
31 // In the cudacc compiler scenario, we will simply ignore the container
32 // printout feature. Basically we need to register a fake overload for
33 // vector/string - here, we just ignore the entries in the logs.
34 
35 namespace std {
36 #define INSTANTIATE_FOR_CONTAINER(container) \
37  template <class... Types> \
38  ostream& operator<<(ostream& out, const container<Types...>&) { \
39  return out; \
40  }
41 
42 INSTANTIATE_FOR_CONTAINER(vector)
43 INSTANTIATE_FOR_CONTAINER(map)
44 INSTANTIATE_FOR_CONTAINER(set)
45 #undef INSTANTIATE_FOR_CONTAINER
46 } // namespace std
47 
48 #endif
49 
50 #include <glog/logging.h>
51 
52 #endif // C10_UTIL_LOGGING_IS_GOOGLE_GLOG_H_