From 7b4916c4b403ba425e9c90af8cb7760f133f38fc Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Sat, 29 Jan 2022 10:35:24 +0800 Subject: [PATCH] [pten] fix wrong variable name in PreparePtenData (#39311) --- paddle/fluid/framework/operator.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/operator.cc b/paddle/fluid/framework/operator.cc index eac4962eae..b7ceb497e5 100644 --- a/paddle/fluid/framework/operator.cc +++ b/paddle/fluid/framework/operator.cc @@ -1877,6 +1877,7 @@ Scope* OperatorWithKernel::PreparePtenData( "the size of kernel input_defs (%d).", input_names.size(), input_defs.size())); Scope* new_scope = nullptr; + auto& name_map = Inputs(); const std::unordered_set* no_buffer_ins = nullptr; if (info_) { auto& no_buffer_inferer = info_->NoNeedBufferVarsInferer(); @@ -1890,6 +1891,7 @@ Scope* OperatorWithKernel::PreparePtenData( for (size_t i = 0; i < input_defs.size(); ++i) { auto& in_def = input_defs.at(i); auto& ins_vector = ctx->inputs.at(input_names[i]); + auto& name_vec = name_map.at(input_names[i]); bool should_skip_input = no_buffer_ins && no_buffer_ins->count(input_names[i]) > 0; @@ -1927,7 +1929,7 @@ Scope* OperatorWithKernel::PreparePtenData( } // Create new var with the same name in transfer scopes - auto* trans_var = new_scope->Var(input_names[i]); + auto* trans_var = new_scope->Var(name_vec[offset]); ins_vector[offset] = trans_var; // Do transfer -- GitLab