diff --git a/paddle/fluid/operators/jit/helper.cc b/paddle/fluid/operators/jit/helper.cc index 992228adb50c8aeea2f4368a5a696787ff384025..2952cdb87146ec01a366abaf332ce1099c425966 100644 --- a/paddle/fluid/operators/jit/helper.cc +++ b/paddle/fluid/operators/jit/helper.cc @@ -22,9 +22,8 @@ namespace paddle { namespace operators { namespace jit { -std::unordered_map>& GetFuncCacheMap() { - static thread_local std::unordered_map> - g_func_cache_map; +std::map>& GetFuncCacheMap() { + static thread_local std::map> g_func_cache_map; return g_func_cache_map; } diff --git a/paddle/fluid/operators/jit/helper.h b/paddle/fluid/operators/jit/helper.h index 9a2447a98fb7bd6337967219437c9d381a8e672b..39e5ee2be1538e7884118a2280ed2e02c5de3bff 100644 --- a/paddle/fluid/operators/jit/helper.h +++ b/paddle/fluid/operators/jit/helper.h @@ -15,6 +15,7 @@ #pragma once #include +#include #include #include #include @@ -176,8 +177,7 @@ typename KernelTuple::func_type GetDefaultBestFunc( return funcs[0]; } -extern std::unordered_map>& -GetFuncCacheMap(); +extern std::map>& GetFuncCacheMap(); template class KernelFuncs { @@ -185,7 +185,7 @@ class KernelFuncs { KernelFuncs() = default; static KernelFuncs& Cache() { auto& func_cache_map = GetFuncCacheMap(); - std::string key = typeid(KernelFuncs).name(); + auto key = typeid(KernelFuncs).hash_code(); auto iter = func_cache_map.find(key); if (iter != func_cache_map.end()) { return *(KernelFuncs*)(iter->second.get()); diff --git a/paddle/fluid/operators/jit/kernel_pool.cc b/paddle/fluid/operators/jit/kernel_pool.cc index 8eef8e474748bfd58dad8b1add91804e48d394ad..f1719be987348b6b8f0ba5c1212808f20c922c78 100644 --- a/paddle/fluid/operators/jit/kernel_pool.cc +++ b/paddle/fluid/operators/jit/kernel_pool.cc @@ -21,9 +21,8 @@ namespace paddle { namespace operators { namespace jit { -std::unordered_map>& GetJITCodesMap() { - static thread_local std::unordered_map> - g_jit_codes_map; +std::map>& GetJITCodesMap() { + static thread_local std::map> g_jit_codes_map; return g_jit_codes_map; } diff --git a/paddle/fluid/operators/jit/kernel_pool.h b/paddle/fluid/operators/jit/kernel_pool.h index 548c87041268a2a24e6c291b6ba8f5518620770a..48435cf6ef25448b548836e5da581609c63dd08f 100644 --- a/paddle/fluid/operators/jit/kernel_pool.h +++ b/paddle/fluid/operators/jit/kernel_pool.h @@ -14,6 +14,7 @@ #pragma once +#include #include // for unique_ptr #include #include @@ -28,7 +29,7 @@ namespace paddle { namespace operators { namespace jit { -extern std::unordered_map>& GetJITCodesMap(); +extern std::map>& GetJITCodesMap(); template class JitCodePool { @@ -39,7 +40,7 @@ class JitCodePool { JitCodePool() = default; static JitCodePool& Instance() { auto& jit_codes_map = GetJITCodesMap(); - std::string key = typeid(JitCodePool).name(); + auto key = typeid(JitCodePool).hash_code(); auto iter = jit_codes_map.find(key); if (iter != jit_codes_map.end()) { return *(JitCodePool*)(iter->second.get());