@@ -274,8 +274,15 @@ void TypeTargetTransformPass::AddInputIoCopyInst(
274274 // So there will be a new Argument node and a new IoCopy Statement Node.
275275
276276 CHECK (in->IsArg ());
277- auto io_copy_output_name =
277+ bool in_persist = in->AsArg ().is_weight || in->AsArg ().is_persist ;
278+ std::string io_copy_output_name;
279+ if (in_persist){
280+ io_copy_output_name =
281+ string_format (" %s/target_trans_persistable" , in->AsArg ().name .c_str ());
282+ }else {
283+ io_copy_output_name =
278284 string_format (" %s/target_trans" , in->AsArg ().name .c_str ());
285+ }
279286
280287 if (copied_nodes->count (in->AsArg ().name )) {
281288 // Remove the old link
@@ -292,7 +299,12 @@ void TypeTargetTransformPass::AddInputIoCopyInst(
292299 // TODO(MyPandaShaoxiang) should set same place with input?
293300 auto * io_copy_output_arg = graph->NewArgumentNode (io_copy_output_name);
294301 // Create the new var manually.
295- auto new_var = inst_node->AsStmt ().op ()->scope ()->Var (io_copy_output_name);
302+ Variable* new_var=nullptr ;
303+ if (in_persist){
304+ new_var = inst_node->AsStmt ().op ()->scope ()->MutableParent ()->Var (io_copy_output_name);
305+ }else {
306+ new_var = inst_node->AsStmt ().op ()->scope ()->Var (io_copy_output_name);
307+ }
296308 // Set the place for io_copy_output_arg node, the target should be equal to
297309 // to.target()
298310 // The precision and layout should be equal to from.precision(),
@@ -316,7 +328,6 @@ void TypeTargetTransformPass::AddInputIoCopyInst(
316328 }
317329 auto * io_copy_inst = graph->NewInstructNode ();
318330
319- bool in_persist = in->AsArg ().is_weight || in->AsArg ().is_persist ;
320331 std::string io_copy_type = in_persist ? " io_copy_once" : " io_copy" ;
321332 io_copy_output_arg->AsArg ().is_persist = in_persist;
322333 // create Op and kernels.
0 commit comments