@@ -100,10 +100,10 @@ public static Tensor eager_safe_variable_handle(Tensor initial_value, TensorShap
100100 /// <param name="shared_name"></param>
101101 /// <param name="name"></param>
102102 /// <param name="graph_mode"></param>
103- /// <param name="extra_handle_data "></param>
103+ /// <param name="initial_value "></param>
104104 /// <returns></returns>
105105 public static Tensor variable_handle_from_shape_and_dtype ( TensorShape shape , TF_DataType dtype ,
106- string shared_name , string name , bool graph_mode , Tensor extra_handle_data = null )
106+ string shared_name , string name , bool graph_mode , Tensor initial_value = null )
107107 {
108108 var container = "" ; // ops.get_default_graph().container;
109109 var handle = gen_resource_variable_ops . var_handle_op ( shape : shape ,
@@ -112,17 +112,22 @@ public static Tensor variable_handle_from_shape_and_dtype(TensorShape shape, TF_
112112 name : name ,
113113 container : container ) ;
114114
115- if ( extra_handle_data == null )
116- extra_handle_data = handle ;
115+ if ( initial_value == null )
116+ initial_value = handle ;
117117
118118 if ( graph_mode )
119119 {
120- var full_handle_data = _combine_handle_data ( handle , extra_handle_data ) ;
120+ var full_handle_data = _combine_handle_data ( handle , initial_value ) ;
121121 _set_handle_shapes_and_types ( handle , full_handle_data , graph_mode ) ;
122122 return handle ;
123123 }
124124 else
125125 {
126+ // We do not want two distinct ResourceVariable objects for the same
127+ // underlying resource in the runtime.
128+ // When in eager mode, explicitly ensure so here. When in graph mode, it's
129+ // ensured by always generating different variable names.
130+ var exists = gen_resource_variable_ops . var_is_initialized_op ( handle ) ;
126131 throw new NotImplementedException ( "" ) ;
127132 }
128133 }
0 commit comments