!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:
commit
db5794141e
|
@ -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);
|
||||
|
|
|
@ -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.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue