未验证 提交 f1704b20 编写于 作者: Z zyfncg 提交者: GitHub

optimiaze performance of PreparePhiData (#42093)

上级 5439f07d
...@@ -581,10 +581,11 @@ void PreparePhiData(const phi::Kernel& pt_kernel, ...@@ -581,10 +581,11 @@ void PreparePhiData(const phi::Kernel& pt_kernel,
for (size_t i = 0; i < input_names.size(); ++i) { for (size_t i = 0; i < input_names.size(); ++i) {
auto& in_def = input_defs.at(i); auto& in_def = input_defs.at(i);
if (ins.find(input_names[i]) == ins.end()) { auto iter = ins.find(input_names[i]);
if (iter == ins.end()) {
continue; continue;
} }
auto& ins_vector = ins.at(input_names[i]); auto& ins_vector = iter->second;
for (size_t offset = 0; offset < ins_vector.size(); ++offset) { for (size_t offset = 0; offset < ins_vector.size(); ++offset) {
auto& var = ins_vector[offset]; auto& var = ins_vector[offset];
...@@ -593,11 +594,15 @@ void PreparePhiData(const phi::Kernel& pt_kernel, ...@@ -593,11 +594,15 @@ void PreparePhiData(const phi::Kernel& pt_kernel,
if (in_def.backend == phi::Backend::ALL_BACKEND) { if (in_def.backend == phi::Backend::ALL_BACKEND) {
continue; continue;
} }
auto expected_place = phi::TransToPhiPlace(in_def.backend); auto tensor_backend = phi::TransToPhiBackend(tensor_in->place());
if (platform::is_same_place(tensor_in->place(), expected_place)) { if (in_def.backend == tensor_backend ||
(in_def.backend == phi::Backend::GPUDNN &&
tensor_backend == phi::Backend::GPU)) {
continue; continue;
} }
auto expected_place = phi::TransToPhiPlace(in_def.backend);
VLOG(3) << "Phi Transform Variable " << input_names[i] << " from " VLOG(3) << "Phi Transform Variable " << input_names[i] << " from "
<< tensor_in->place() << " to " << expected_place; << tensor_in->place() << " to " << expected_place;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册