1- using System ;
1+ using OneOf ;
2+ using System ;
23using System . Collections . Generic ;
34using System . Diagnostics ;
45using System . Linq ;
56using System . Text ;
67using Tensorflow . Train ;
78using Tensorflow . Training ;
9+ using Tensorflow . Common . Extensions ;
810using pbc = global ::Google . Protobuf . Collections ;
911
1012namespace Tensorflow . Checkpoint
@@ -28,7 +30,7 @@ Trackable object_to_save
2830 ) ;
2931 public static class SaveUtil
3032 {
31- public static ( IDictionary < Trackable , IDictionary < string , Maybe < Tensor , IDictionary < string , Tensor > > > > , IDictionary < Tensor , object > , IDictionary < string , IDictionary < string , Trackable > > , TrackableObjectGraph )
33+ public static ( IDictionary < Trackable , IDictionary < string , OneOf < Tensor , IDictionary < string , Tensor > > > > , IDictionary < Tensor , object > , IDictionary < string , IDictionary < string , Trackable > > , TrackableObjectGraph )
3234 serialize_graph_view ( ObjectGraphView graph_view , IDictionary < Trackable , Trackable > ? object_map = null , bool call_with_mapped_captures = false , object ? cache = null )
3335 {
3436 var ( trackable_data , node_ids ) = gather_trackable_data ( graph_view , object_map ) ;
@@ -117,16 +119,16 @@ private static TrackableObjectGraph fill_object_graph_proto(IList<TrackableData>
117119 /// <param name="call_with_mapped_captures"></param>
118120 /// <param name="cache"></param>
119121 /// <param name="object_graph_proto"></param>
120- private static IDictionary < Trackable , IDictionary < string , Maybe < Tensor , IDictionary < string , Tensor > > > > get_and_write_tensors_to_serialize ( IList < TrackableData > tensor_trackables , IDictionary < Trackable , int > node_ids ,
122+ private static IDictionary < Trackable , IDictionary < string , OneOf < Tensor , IDictionary < string , Tensor > > > > get_and_write_tensors_to_serialize ( IList < TrackableData > tensor_trackables , IDictionary < Trackable , int > node_ids ,
121123 bool call_with_mapped_captures , object ? cache , TrackableObjectGraph object_graph_proto )
122124 {
123- Dictionary < Trackable , IDictionary < string , Maybe < Tensor , IDictionary < string , Tensor > > > > serialized_tensors = new ( ) ;
125+ Dictionary < Trackable , IDictionary < string , OneOf < Tensor , IDictionary < string , Tensor > > > > serialized_tensors = new ( ) ;
124126 foreach ( var td in tensor_trackables )
125127 {
126128 // TODO: deal with cache.
127129 var legacy_name = SaveableCompat . get_saveable_name ( td . object_to_save ) ?? "" ;
128130 Trackable trackable = null ;
129- IDictionary < string , Maybe < Tensor , IDictionary < string , Tensor > > > tensor_dict ;
131+ IDictionary < string , OneOf < Tensor , IDictionary < string , Tensor > > > tensor_dict ;
130132 if ( ! saveable_object_util . trackable_has_serialize_to_tensor ( td . object_to_save ) || legacy_name . Length > 0 )
131133 {
132134 ( trackable , tensor_dict ) = get_tensors_from_legacy_saveable ( td , node_ids , call_with_mapped_captures , object_graph_proto ) ;
@@ -148,12 +150,12 @@ private static IDictionary<Trackable, IDictionary<string, Maybe<Tensor, IDiction
148150 return serialized_tensors ;
149151 }
150152
151- private static IDictionary < string , Maybe < Tensor , IDictionary < string , Tensor > > > get_tensors_from_trackable ( TrackableData trackable_data , bool call_with_mapped_captures , TrackableObjectGraph object_graph_proto )
153+ private static IDictionary < string , OneOf < Tensor , IDictionary < string , Tensor > > > get_tensors_from_trackable ( TrackableData trackable_data , bool call_with_mapped_captures , TrackableObjectGraph object_graph_proto )
152154 {
153155 var trackable = trackable_data . object_to_save ;
154156
155157 // TODO: complete it. Note that actually `call_with_mapped_captures` is of function type.
156- IDictionary < string , Maybe < Tensor , IDictionary < string , Tensor > > > ret_tensor_dict ;
158+ IDictionary < string , OneOf < Tensor , IDictionary < string , Tensor > > > ret_tensor_dict ;
157159 if ( call_with_mapped_captures )
158160 {
159161 throw new NotImplementedException ( ) ;
@@ -164,7 +166,7 @@ private static IDictionary<string, Maybe<Tensor, IDictionary<string, Tensor>>> g
164166 }
165167
166168 // TODO: deal with the type `SaveSpce` (currently it will never be it).
167- Dictionary < string , Maybe < Tensor , IDictionary < string , Tensor > > > tensor_dict = new ( ) ;
169+ Dictionary < string , OneOf < Tensor , IDictionary < string , Tensor > > > tensor_dict = new ( ) ;
168170 foreach ( var pair in ret_tensor_dict )
169171 {
170172 var local_name = TrackableUtils . escape_local_name ( pair . Key ) ;
@@ -200,7 +202,7 @@ private static IDictionary<string, Maybe<Tensor, IDictionary<string, Tensor>>> g
200202 /// <param name="call_with_mapped_captures"></param>
201203 /// <param name="object_graph_proto"></param>
202204 /// <returns></returns>
203- private static ( Trackable , IDictionary < string , Maybe < Tensor , IDictionary < string , Tensor > > > ) get_tensors_from_legacy_saveable ( TrackableData trackable_data , IDictionary < Trackable , int > node_ids ,
205+ private static ( Trackable , IDictionary < string , OneOf < Tensor , IDictionary < string , Tensor > > > ) get_tensors_from_legacy_saveable ( TrackableData trackable_data , IDictionary < Trackable , int > node_ids ,
204206 bool call_with_mapped_captures , TrackableObjectGraph object_graph_proto )
205207 {
206208 Dictionary < Trackable , string > object_names = new ( ) ;
0 commit comments