From e6c68a2d978ce031be25cd4f3fdbb9c422bd6e4c Mon Sep 17 00:00:00 2001 From: Kavya Srinet Date: Wed, 14 Feb 2018 10:18:06 -0800 Subject: [PATCH] Fixed data_type.h --- paddle/fluid/framework/data_type.h | 54 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/paddle/fluid/framework/data_type.h b/paddle/fluid/framework/data_type.h index 127bbcf5d00..f1186c44742 100644 --- a/paddle/fluid/framework/data_type.h +++ b/paddle/fluid/framework/data_type.h @@ -20,35 +20,35 @@ limitations under the License. */ namespace paddle { namespace framework { -inline proto::DataType ToDataType(std::type_index type) { +inline proto::VarType::Type ToDataType(std::type_index type) { using namespace paddle::framework::proto; if (typeid(float).hash_code() == type.hash_code()) { - return DataType::FP32; + return VarType::Type::FP32; } else if (typeid(double).hash_code() == type.hash_code()) { - return DataType::FP64; + return VarType::Type::FP64; } else if (typeid(int).hash_code() == type.hash_code()) { - return DataType::INT32; + return VarType::Type::INT32; } else if (typeid(int64_t).hash_code() == type.hash_code()) { - return DataType::INT64; + return VarType::Type::INT64; } else if (typeid(bool).hash_code() == type.hash_code()) { - return DataType::BOOL; + return VarType::Type::BOOL; } else { PADDLE_THROW("Not supported"); } } -inline std::type_index ToTypeIndex(proto::DataType type) { +inline std::type_index ToTypeIndex(proto::VarType::Type type) { using namespace paddle::framework::proto; switch (type) { - case DataType::FP32: + case VarType::Type::FP32: return typeid(float); - case DataType::FP64: + case VarType::Type::FP64: return typeid(double); - case DataType::INT32: + case VarType::Type::INT32: return typeid(int); - case DataType::INT64: + case VarType::Type::INT64: return typeid(int64_t); - case DataType::BOOL: + case VarType::Type::BOOL: return typeid(bool); default: PADDLE_THROW("Not support type %d", type); @@ -56,22 +56,22 @@ inline std::type_index ToTypeIndex(proto::DataType type) { } template -inline void VisitDataType(proto::DataType type, Visitor visitor) { +inline void VisitDataType(proto::VarType::Type type, Visitor visitor) { using namespace paddle::framework::proto; switch (type) { - case DataType::FP32: + case VarType::Type::FP32: visitor.template operator()(); break; - case DataType::FP64: + case VarType::Type::FP64: visitor.template operator()(); break; - case DataType::INT32: + case VarType::Type::INT32: visitor.template operator()(); break; - case DataType::INT64: + case VarType::Type::INT64: visitor.template operator()(); break; - case DataType::BOOL: + case VarType::Type::BOOL: visitor.template operator()(); break; default: @@ -79,22 +79,22 @@ inline void VisitDataType(proto::DataType type, Visitor visitor) { } } -inline std::string DataTypeToString(const proto::DataType type) { +inline std::string DataTypeToString(const proto::VarType::Type type) { using namespace paddle::framework::proto; switch (type) { - case DataType::FP16: + case VarType::Type::FP16: return "float16"; - case DataType::FP32: + case VarType::Type::FP32: return "float32"; - case DataType::FP64: + case VarType::Type::FP64: return "float64"; - case DataType::INT16: + case VarType::Type::INT16: return "int16"; - case DataType::INT32: + case VarType::Type::INT32: return "int32"; - case DataType::INT64: + case VarType::Type::INT64: return "int64"; - case DataType::BOOL: + case VarType::Type::BOOL: return "bool"; default: PADDLE_THROW("Not support type %d", type); @@ -102,7 +102,7 @@ inline std::string DataTypeToString(const proto::DataType type) { } inline std::ostream& operator<<(std::ostream& out, - const proto::DataType& type) { + const proto::VarType::Type& type) { out << DataTypeToString(type); return out; } -- GitLab