diff --git a/paddle/fluid/framework/executor_cache.h b/paddle/fluid/framework/executor_cache.h index 3a5930c0c47593a19c30b0a1b702b508f9532d98..edbbc0e9420afef6d9cc1ee1f400301540dac2a6 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); }