!45086 fix the address of subgraphs share the same ref input parameter

Merge pull request !45086 from limingqi107/bug_fix3
This commit is contained in:
i-robot 2022-11-04 01:20:57 +00:00 committed by Gitee
commit db5794141e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 11 additions and 5 deletions

View File

@ -234,9 +234,14 @@ void UpdateDeviceAddressByRefInputNode(const std::vector<KernelGraphPtr> &graphs
<< " by the modified ref input parameter: " << input_pair.first->fullname_with_scope();
auto ref_node_output_addr = AnfAlgo::GetMutableOutputAddr(output_pair.first, output_pair.second, false);
MS_EXCEPTION_IF_NULL(ref_node_output_addr);
const auto &front_input_node = graph->GetFrontAnfByBackendAnf(input_pair.first);
const auto &input_addr =
const auto &front_input_node = AnfAlgo::FetchFrontNodeByBackendNode(input_pair.first, *graph);
auto input_addr =
DeviceTensorStore::GetInstance().Fetch(front_input_node.get(), ref_node_output_addr->GetDeviceType());
// Maybe subgraphs share the same backend input parameter, so fetch device tensor store by front node of this
// subgraph maybe nullptr and use the output addr of input parameter directly.
if (input_addr == nullptr) {
input_addr = AnfAlgo::GetMutableOutputAddr(input_pair.first, input_pair.second, false);
}
MS_EXCEPTION_IF_NULL(input_addr);
ref_node_output_addr->set_ptr(input_addr->GetMutablePtr());
ref_node_output_addr->set_original_ref_count(SIZE_MAX);

View File

@ -655,9 +655,10 @@ bool KernelActor::LaunchKernel(OpContext<DeviceTensor> *const) {
MS_EXCEPTION_IF_NULL(launch_info_.inputs_[input_index]);
MS_EXCEPTION_IF_NULL(launch_info_.outputs_[output_index]);
if (launch_info_.inputs_[input_index]->addr != launch_info_.outputs_[output_index]->addr) {
MS_LOG(ERROR) << "Input address and output address are not equal of ref kernel actor: " << GetAID().Name()
<< ", input index: " << input_index << ", output index: " << output_index;
return false;
// Ref node may not use the output addr, so only print the warning info.
MS_LOG(WARNING) << "Input address and output address are not equal of ref kernel actor: " << GetAID().Name()
<< ", ref input index: " << input_index << ", ref output index: " << output_index
<< ". Please check whether the output address is used, which may cause problems.";
}
}