提交 1d4d4e73 编写于 作者: Y Yu Yang

Remove place hash

test=develop
上级 461f71a9
......@@ -193,8 +193,7 @@ class CUDAPinnedManagedAllocator : public ChunkedManagedAllocator {
class AllocatorFacadePrivate {
public:
std::unordered_map<platform::Place, std::shared_ptr<ManagedAllocator>>
allocators_;
std::map<platform::Place, std::shared_ptr<ManagedAllocator>> allocators_;
~AllocatorFacadePrivate() = default;
......
......@@ -131,65 +131,5 @@ typename Visitor::result_type VisitPlace(const Place &place,
return boost::apply_visitor(PlaceVisitorWrapper<Visitor>(visitor), place);
}
struct PlaceHashVisitor : public boost::static_visitor<size_t> {
template <typename Place>
inline size_t operator()(const Place &place) const {
return place.hash();
}
};
} // namespace platform
} // namespace paddle
namespace std {
template <>
struct hash<::paddle::platform::CPUPlace> {
using argument_type = ::paddle::platform::CPUPlace;
using result_type = size_t;
constexpr inline result_type operator()(const argument_type &place) const {
return static_cast<result_type>(-1);
}
};
template <>
struct hash<::paddle::platform::CUDAPlace> {
using argument_type = ::paddle::platform::CUDAPlace;
using result_type = size_t;
inline result_type operator()(const argument_type &place) const {
return static_cast<result_type>(place.device);
}
};
template <>
struct hash<::paddle::platform::CUDAPinnedPlace> {
using argument_type = ::paddle::platform::CUDAPinnedPlace;
using result_type = size_t;
constexpr inline result_type operator()(const argument_type &place) const {
return static_cast<result_type>(-2);
}
};
namespace { // NOLINT
struct PlaceHashVisitor : public boost::static_visitor<size_t> {
template <typename Place>
inline size_t operator()(const Place &place) const {
return std::hash<Place>()(place);
}
};
}
template <>
struct hash<::paddle::platform::Place> {
using argument_type = ::paddle::platform::Place;
using result_type = size_t;
inline result_type operator()(const argument_type &place) const {
return boost::apply_visitor(PlaceHashVisitor(), place);
}
};
} // namespace std
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册