@@ -50,7 +50,8 @@ public static object get_collection_ref(string key)
5050 return get_default_graph ( ) . get_collection_ref ( key ) ;
5151 }
5252
53- private static Graph default_graph ;
53+ public static DefaultGraphStack default_graph_stack = new DefaultGraphStack ( ) ;
54+
5455 /// <summary>
5556 /// Returns the default graph for the current thread.
5657 ///
@@ -68,15 +69,13 @@ public static Graph get_default_graph()
6869 {
6970 //TODO: original source indicates there should be a _default_graph_stack!
7071 //return _default_graph_stack.get_default()
71- if ( default_graph == null )
72- default_graph = tf . Graph ( ) ;
73- return default_graph ;
72+ return default_graph_stack . get_controller ( ) ;
7473 }
7574 public static Graph set_default_graph ( Graph graph )
7675 {
7776 //TODO: original source does not have a 'set_default_graph' and indicates there should be a _default_graph_stack!
78- default_graph = graph ;
79- return default_graph ;
77+ default_graph_stack . set_controller ( graph ) ;
78+ return default_graph_stack . get_controller ( ) ;
8079 }
8180
8281 /// <summary>
@@ -96,10 +95,7 @@ public static void reset_default_graph()
9695 // throw new InvalidOperationException("Do not use tf.reset_default_graph() to clear " +
9796 // "nested graphs. If you need a cleared graph, " +
9897 // "exit the nesting and create a new graph.");
99- //_default_graph_stack.reset();
100- if ( default_graph != null )
101- default_graph . Dispose ( ) ;
102- default_graph = tf . Graph ( ) ;
98+ default_graph_stack . reset ( ) ;
10399 }
104100
105101 public static Graph _get_graph_from_inputs ( params Tensor [ ] op_input_list )
0 commit comments