提交 f380ee4e 编写于 作者: K Kavya Srinet

Updated format of type in data_type.h

上级 9d5ff82e
...@@ -23,15 +23,15 @@ namespace framework { ...@@ -23,15 +23,15 @@ namespace framework {
inline proto::VarType::Type ToDataType(std::type_index type) { inline proto::VarType::Type ToDataType(std::type_index type) {
using namespace paddle::framework::proto; using namespace paddle::framework::proto;
if (typeid(float).hash_code() == type.hash_code()) { if (typeid(float).hash_code() == type.hash_code()) {
return VarType_Type_FP32; return proto::VarType::FP32;
} else if (typeid(double).hash_code() == type.hash_code()) { } else if (typeid(double).hash_code() == type.hash_code()) {
return VarType_Type_FP64; return proto::VarType::FP64;
} else if (typeid(int).hash_code() == type.hash_code()) { } else if (typeid(int).hash_code() == type.hash_code()) {
return VarType_Type_INT32; return proto::VarType::INT32;
} else if (typeid(int64_t).hash_code() == type.hash_code()) { } else if (typeid(int64_t).hash_code() == type.hash_code()) {
return VarType_Type_INT64; return proto::VarType::INT64;
} else if (typeid(bool).hash_code() == type.hash_code()) { } else if (typeid(bool).hash_code() == type.hash_code()) {
return VarType_Type_BOOL; return proto::VarType::BOOL;
} else { } else {
PADDLE_THROW("Not supported"); PADDLE_THROW("Not supported");
} }
...@@ -40,15 +40,15 @@ inline proto::VarType::Type ToDataType(std::type_index type) { ...@@ -40,15 +40,15 @@ inline proto::VarType::Type ToDataType(std::type_index type) {
inline std::type_index ToTypeIndex(proto::VarType::Type type) { inline std::type_index ToTypeIndex(proto::VarType::Type type) {
using namespace paddle::framework::proto; using namespace paddle::framework::proto;
switch (type) { switch (type) {
case VarType_Type_FP32: case proto::VarType::FP32:
return typeid(float); return typeid(float);
case VarType_Type_FP64: case proto::VarType::FP64:
return typeid(double); return typeid(double);
case VarType_Type_INT32: case proto::VarType::INT32:
return typeid(int); return typeid(int);
case VarType_Type_INT64: case proto::VarType::INT64:
return typeid(int64_t); return typeid(int64_t);
case VarType_Type_BOOL: case proto::VarType::BOOL:
return typeid(bool); return typeid(bool);
default: default:
PADDLE_THROW("Not support type %d", type); PADDLE_THROW("Not support type %d", type);
...@@ -59,19 +59,19 @@ template <typename Visitor> ...@@ -59,19 +59,19 @@ template <typename Visitor>
inline void VisitDataType(proto::VarType::Type type, Visitor visitor) { inline void VisitDataType(proto::VarType::Type type, Visitor visitor) {
using namespace paddle::framework::proto; using namespace paddle::framework::proto;
switch (type) { switch (type) {
case VarType_Type_FP32: case proto::VarType::FP32:
visitor.template operator()<float>(); visitor.template operator()<float>();
break; break;
case VarType_Type_FP64: case proto::VarType::FP64:
visitor.template operator()<double>(); visitor.template operator()<double>();
break; break;
case VarType_Type_INT32: case proto::VarType::INT32:
visitor.template operator()<int>(); visitor.template operator()<int>();
break; break;
case VarType_Type_INT64: case proto::VarType::INT64:
visitor.template operator()<int64_t>(); visitor.template operator()<int64_t>();
break; break;
case VarType_Type_BOOL: case proto::VarType::BOOL:
visitor.template operator()<bool>(); visitor.template operator()<bool>();
break; break;
default: default:
...@@ -82,19 +82,19 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) { ...@@ -82,19 +82,19 @@ inline void VisitDataType(proto::VarType::Type type, Visitor visitor) {
inline std::string DataTypeToString(const proto::VarType::Type type) { inline std::string DataTypeToString(const proto::VarType::Type type) {
using namespace paddle::framework::proto; using namespace paddle::framework::proto;
switch (type) { switch (type) {
case VarType_Type_FP16: case proto::VarType::FP16:
return "float16"; return "float16";
case VarType_Type_FP32: case proto::VarType::FP32:
return "float32"; return "float32";
case VarType_Type_FP64: case proto::VarType::FP64:
return "float64"; return "float64";
case VarType_Type_INT16: case proto::VarType::INT16:
return "int16"; return "int16";
case VarType_Type_INT32: case proto::VarType::INT32:
return "int32"; return "int32";
case VarType_Type_INT64: case proto::VarType::INT64:
return "int64"; return "int64";
case VarType_Type_BOOL: case proto::VarType::BOOL:
return "bool"; return "bool";
default: default:
PADDLE_THROW("Not support type %d", type); PADDLE_THROW("Not support type %d", type);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册