@@ -44,8 +44,7 @@ public static void update_checkpoint_state_internal(string save_dir,
4444 float ? last_preserved_timestamp = null
4545 )
4646 {
47- CheckpointState ckpt = null ;
48-
47+ CheckpointState ckpt = null ;
4948 // Writes the "checkpoint" file for the coordinator for later restoration.
5049 string coord_checkpoint_filename = _GetCheckpointFilename ( save_dir , latest_filename ) ;
5150 if ( save_relative_paths )
@@ -65,7 +64,12 @@ public static void update_checkpoint_state_internal(string save_dir,
6564 throw new RuntimeError ( $ "Save path '{ model_checkpoint_path } ' conflicts with path used for " +
6665 "checkpoint state. Please use a different save path." ) ;
6766
68- File . WriteAllText ( coord_checkpoint_filename , ckpt . ToString ( ) ) ;
67+ // File.WriteAllText(coord_checkpoint_filename, ckpt.ToString());
68+ File . WriteAllLines ( coord_checkpoint_filename , new [ ]
69+ {
70+ $ "model_checkpoint_path: \" { ckpt . ModelCheckpointPath } \" ",
71+ $ "all_model_checkpoint_paths: \" { ckpt . AllModelCheckpointPaths [ 0 ] } \" ",
72+ } ) ;
6973 }
7074
7175 /// <summary>
@@ -98,7 +102,14 @@ private static CheckpointState generate_checkpoint_state_proto(string save_dir,
98102 all_model_checkpoint_paths . Add ( model_checkpoint_path ) ;
99103
100104 // Relative paths need to be rewritten to be relative to the "save_dir"
101- // if model_checkpoint_path already contains "save_dir".
105+ if ( model_checkpoint_path . StartsWith ( save_dir ) )
106+ {
107+ model_checkpoint_path = model_checkpoint_path . Substring ( save_dir . Length + 1 ) ;
108+ all_model_checkpoint_paths = all_model_checkpoint_paths
109+ . Select ( x => x . Substring ( save_dir . Length + 1 ) )
110+ . ToList ( ) ;
111+ }
112+
102113
103114 var coord_checkpoint_proto = new CheckpointState ( )
104115 {
0 commit comments