未验证 提交 5f9d6d68 编写于 作者: H hong 提交者: GitHub

add cache id flags (#56616)

上级 636dc2ff
......@@ -34,6 +34,7 @@
#include "paddle/ir/core/ir_context.h"
#include "paddle/ir/core/program.h"
PHI_DECLARE_bool(enable_new_ir_in_executor);
namespace paddle {
namespace framework {
namespace ir {
......@@ -188,8 +189,10 @@ class InterpreterCoreInfoCache {
static InterpreterCoreInfoCache& Instance();
bool Has(int64_t program_id, const framework::Scope* scope, bool is_grad) {
int64_t scope_i = reinterpret_cast<std::uintptr_t>(scope);
program_id += 0x9e3779b9 + (program_id << 6) + (scope_i >> 2);
if (FLAGS_enable_new_ir_in_executor) {
int64_t scope_i = reinterpret_cast<std::uintptr_t>(scope);
program_id += 0x9e3779b9 + (program_id << 6) + (scope_i >> 2);
}
return info_map_.find(program_id) != info_map_.end() &&
info_map_[program_id].IsAvailable(is_grad);
}
......@@ -197,8 +200,10 @@ class InterpreterCoreInfoCache {
InterpreterCoreInfo::CacheValue& GetMutable(int64_t program_id,
const framework::Scope* scope,
bool is_grad) {
int64_t scope_i = reinterpret_cast<std::uintptr_t>(scope);
program_id += 0x9e3779b9 + (program_id << 6) + (scope_i >> 2);
if (FLAGS_enable_new_ir_in_executor) {
int64_t scope_i = reinterpret_cast<std::uintptr_t>(scope);
program_id += 0x9e3779b9 + (program_id << 6) + (scope_i >> 2);
}
return info_map_[program_id].GetMutable(is_grad);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册