1 #ifndef CAFFE2_CORE_TYPES_H_ 2 #define CAFFE2_CORE_TYPES_H_ 8 #include "caffe2/core/common.h" 9 #include "caffe2/core/logging.h" 10 #include "caffe2/core/typeid.h" 11 #include "caffe2/proto/caffe2.pb.h" 22 inline StorageOrder StringToStorageOrder(
const string& str) {
23 if (str ==
"NHWC" || str ==
"nhwc") {
24 return StorageOrder::NHWC;
25 }
else if (str ==
"NCHW" || str ==
"nchw") {
26 return StorageOrder::NCHW;
28 LOG(ERROR) <<
"Unknown storage order string: " << str;
29 return StorageOrder::UNKNOWN;
33 inline constexpr
char NameScopeSeparator() {
return '/'; }
36 TensorProto::DataType TypeMetaToDataType(
const TypeMeta& meta);
39 const TypeMeta& DataTypeToTypeMeta(
const TensorProto::DataType& dt);
50 static_assert(
sizeof(
unsigned short) == 2,
51 "Short on this platform is not 16 bit.");
53 typedef struct CAFFE2_ALIGNED(2) __f16 { uint16_t x; } float16;
59 struct is_fundamental<
caffe2::__f16> : std::integral_constant<bool, true> {
63 #endif // CAFFE2_CORE_TYPES_H_
Simple registry implementation in Caffe2 that uses static variables to register object creators durin...