forked from mindspore-Ecosystem/mindspore
!374 share mem of parameter between child graphs
Merge pull request !374 from chenfei/share-mem-of-parameter-between-child-graph
This commit is contained in:
commit
9d2bd1b7e5
|
@ -337,10 +337,6 @@ bool IsNopNode(const AnfNodePtr &node) {
|
|||
if (nop_nodes.find(AnfAlgo::GetCNodeName(cnode)) == nop_nodes.end()) {
|
||||
return false;
|
||||
}
|
||||
if (cnode->inputs().size() != 2) {
|
||||
MS_LOG(EXCEPTION) << "Nop node(" + cnode->DebugString() + ") should have only 1 input, but it has "
|
||||
<< cnode->inputs().size() - 1 << " inputs.";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -709,18 +709,17 @@ void AscendSession::SetChildGraphParameter(const AnfNodePtr &front_anf, const An
|
|||
<< "of graph " << AnfAlgo::GetGraphId(backend_arg.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
// if a parameter is a weight and not linked to any executable node,device type will be kTypeUnknown,set it's device
|
||||
// type same to arg
|
||||
if (AnfAlgo::GetOutputDeviceDataType(backend_parameter, 0) == kTypeUnknown) {
|
||||
AnfAlgo::SetSelectKernelBuildInfo(AnfAlgo::GetSelectKernelBuildInfo(backend_arg), backend_parameter.get());
|
||||
// if a parameter is a weight and not linked to any executable node,device type will be kTypeUnknown,set it's device
|
||||
// type same to arg
|
||||
if (AnfAlgo::GetOutputDeviceDataType(backend_parameter, 0) == kTypeUnknown) {
|
||||
AnfAlgo::SetSelectKernelBuildInfo(AnfAlgo::GetSelectKernelBuildInfo(backend_arg), backend_parameter.get());
|
||||
}
|
||||
// if front anf is a parameter,we can assign the value back,because backend_parameter won't be change in it's graph
|
||||
// unless it's a weight.If backend_parameter is a weight,we should assign the value back.
|
||||
AnfAlgo::SetOutputAddr(AnfAlgo::GetMutableOutputAddr(backend_arg, 0), 0, backend_parameter.get());
|
||||
return;
|
||||
}
|
||||
InsertAssignToGraph(from_graph_id, backend_arg, backend_parameter);
|
||||
// if front anf is a parameter,we can assign the value back,because backend_parameter won't be change in it's graph
|
||||
// unless it's a weigth.If backend_parameter is a weight,we do should assign the value back
|
||||
if (backend_arg->isa<Parameter>() && !to_graph->execution_order().empty()) {
|
||||
InsertAssignToGraph(to_graph_id, backend_parameter, backend_arg);
|
||||
}
|
||||
MS_LOG(INFO) << "Finish!";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue