From 9f8d86858ea6156422c1cf2c59fdb516cb3f7868 Mon Sep 17 00:00:00 2001 From: Yu Yang Date: Tue, 11 Dec 2018 10:43:50 +0800 Subject: [PATCH] Revert data_type test=develop --- paddle/fluid/framework/data_type.cc | 15 +++++++-------- paddle/fluid/framework/parallel_executor.cc | 3 +++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/framework/data_type.cc b/paddle/fluid/framework/data_type.cc index 1c29a89bffa..28f3da88fa1 100644 --- a/paddle/fluid/framework/data_type.cc +++ b/paddle/fluid/framework/data_type.cc @@ -14,7 +14,6 @@ #include "paddle/fluid/framework/data_type.h" #include -#include #include #include @@ -24,10 +23,10 @@ namespace paddle { namespace framework { struct DataTypeMap { - std::map cpp_to_proto_; + std::unordered_map cpp_to_proto_; std::unordered_map proto_to_cpp_; std::unordered_map proto_to_str_; - std::map cpp_to_size_; + std::unordered_map cpp_to_size_; }; static DataTypeMap* InitDataTypeMap(); @@ -44,9 +43,9 @@ static inline void RegisterType(DataTypeMap* map, proto::VarType::Type proto_type, const std::string& name) { map->proto_to_cpp_.emplace(static_cast(proto_type), typeid(T)); - map->cpp_to_proto_.emplace(typeid(T).name(), proto_type); + map->cpp_to_proto_.emplace(typeid(T), proto_type); map->proto_to_str_.emplace(static_cast(proto_type), name); - map->cpp_to_size_.emplace(typeid(T).name(), sizeof(T)); + map->cpp_to_size_.emplace(typeid(T), sizeof(T)); } static DataTypeMap* InitDataTypeMap() { @@ -72,7 +71,7 @@ static DataTypeMap* InitDataTypeMap() { } proto::VarType::Type ToDataType(std::type_index type) { - auto it = gDataTypeMap().cpp_to_proto_.find(type.name()); + auto it = gDataTypeMap().cpp_to_proto_.find(type); if (it != gDataTypeMap().cpp_to_proto_.end()) { return it->second; } @@ -98,8 +97,8 @@ std::string DataTypeToString(const proto::VarType::Type type) { } size_t SizeOfType(std::type_index type) { - auto it = gDataTypeMap().cpp_to_size_.find(type.name()); - if (LIKELY(it != gDataTypeMap().cpp_to_size_.end())) { + auto it = gDataTypeMap().cpp_to_size_.find(type); + if (it != gDataTypeMap().cpp_to_size_.end()) { return it->second; } PADDLE_THROW("Not support %s as tensor type", type.name()); diff --git a/paddle/fluid/framework/parallel_executor.cc b/paddle/fluid/framework/parallel_executor.cc index 0636b89048f..28a4b14b27b 100644 --- a/paddle/fluid/framework/parallel_executor.cc +++ b/paddle/fluid/framework/parallel_executor.cc @@ -39,8 +39,11 @@ DEFINE_string(pe_profile_fname, "", namespace paddle { namespace framework { + static std::once_flag gProfileOnce; +#ifdef WITH_GPERFTOOLS static bool gProfileStarted = false; +#endif class ParallelExecutorPrivate { public: explicit ParallelExecutorPrivate(const std::vector &places) -- GitLab