!9549 fix output value error when run single op in graph mode

From: @chujinjin
Reviewed-by: @kisnwang,@jjfeing
Signed-off-by: @jjfeing
This commit is contained in:
mindspore-ci-bot 2020-12-07 10:23:11 +08:00 committed by Gitee
commit bf5ebcf008
1 changed files with 8 additions and 0 deletions

View File

@ -1124,13 +1124,21 @@ void SessionBasic::UpdateOutputs(const std::shared_ptr<KernelGraph> &kernel_grap
outputs->emplace_back(CreateNodeOutputTensors(item, kernel_graph, input_tensors, &tensor_to_node));
}
auto ms_context = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(ms_context);
for (auto &item : tensor_to_node) {
auto &tensor = item.first;
auto &node = item.second.first;
auto &output_index = item.second.second;
auto address = AnfAlgo::GetMutableOutputAddr(node, output_index);
MS_EXCEPTION_IF_NULL(tensor);
tensor->set_device_address(address);
tensor->SetNeedWait(false);
if (ms_context->get_param<int>(MS_CTX_EXECUTION_MODE) != kPynativeMode) {
tensor->data_sync(false);
tensor->set_sync_status(kNeedSyncHostToDevice);
}
}
}