From 5f9d6d6844f331ae27bb710e4a4b7bac14f3225c Mon Sep 17 00:00:00 2001 From: hong <43953930+phlrain@users.noreply.github.com> Date: Fri, 25 Aug 2023 13:08:36 +0800 Subject: [PATCH] add cache id flags (#56616) --- paddle/fluid/framework/executor_cache.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/framework/executor_cache.h b/paddle/fluid/framework/executor_cache.h index 3a5930c0c47..edbbc0e9420 100644 --- a/paddle/fluid/framework/executor_cache.h +++ b/paddle/fluid/framework/executor_cache.h @@ -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(scope); - program_id += 0x9e3779b9 + (program_id << 6) + (scope_i >> 2); + if (FLAGS_enable_new_ir_in_executor) { + int64_t scope_i = reinterpret_cast(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(scope); - program_id += 0x9e3779b9 + (program_id << 6) + (scope_i >> 2); + if (FLAGS_enable_new_ir_in_executor) { + int64_t scope_i = reinterpret_cast(scope); + program_id += 0x9e3779b9 + (program_id << 6) + (scope_i >> 2); + } return info_map_[program_id].GetMutable(is_grad); } -- GitLab