@@ -105,10 +105,13 @@ public int[] shape
105105
106106 if ( _handle == IntPtr . Zero )
107107 {
108- var status = new Status ( ) ;
109- c_api . TF_GraphGetTensorShape ( op . graph , _as_tf_output ( ) , dims , rank , status ) ;
110- status . Check ( ) ;
111- } else
108+ using ( var status = new Status ( ) )
109+ {
110+ c_api . TF_GraphGetTensorShape ( op . graph , _as_tf_output ( ) , dims , rank , status ) ;
111+ status . Check ( ) ;
112+ }
113+ }
114+ else
112115 {
113116 for ( int i = 0 ; i < rank ; i ++ )
114117 dims [ i ] = c_api . TF_Dim ( _handle , i ) ;
@@ -119,14 +122,15 @@ public int[] shape
119122
120123 set
121124 {
122- var status = new Status ( ) ;
123-
124- if ( value == null )
125- c_api . TF_GraphSetTensorShape ( this . graph , this . _as_tf_output ( ) , null , - 1 , status ) ;
126- else
127- c_api . TF_GraphSetTensorShape ( this . graph , this . _as_tf_output ( ) , value . Select ( Convert . ToInt64 ) . ToArray ( ) , value . Length , status ) ;
125+ using ( var status = new Status ( ) )
126+ {
127+ if ( value == null )
128+ c_api . TF_GraphSetTensorShape ( this . graph , this . _as_tf_output ( ) , null , - 1 , status ) ;
129+ else
130+ c_api . TF_GraphSetTensorShape ( this . graph , this . _as_tf_output ( ) , value . Select ( Convert . ToInt64 ) . ToArray ( ) , value . Length , status ) ;
128131
129- status . Check ( true ) ;
132+ status . Check ( true ) ;
133+ }
130134 }
131135 }
132136
@@ -142,16 +146,7 @@ public int[] _shape_tuple()
142146 /// </summary>
143147 public void set_shape ( TensorShape shape )
144148 {
145- this . shape = ( int [ ] ) shape . dims . Clone ( ) ;
146- }
147-
148- /// <summary>
149- /// Updates the shape of this tensor.
150- /// </summary>
151- [ Obsolete ( "Please use set_shape(TensorShape shape) instead." , false ) ]
152- public void SetShape ( TensorShape shape )
153- {
154- this . shape = ( int [ ] ) shape . dims . Clone ( ) ;
149+ this . shape = shape . rank > 0 ? shape . dims : null ;
155150 }
156151
157152 /// <summary>
0 commit comments