@@ -152,16 +152,16 @@ private NDArray[] _do_run(List<Operation> target_list, List<Tensor> fetch_list,
152152 {
153153
154154 var feeds = new KeyValuePair < TF_Output , Tensor > [ feed_dict . Count ] ;
155- var ignoreDispose = new bool [ feed_dict . Count ] ;
156155 int i = 0 ;
157156 foreach ( var x in feed_dict )
158157 {
159158 if ( x . Key is Tensor tensor )
160159 {
161160 switch ( x . Value )
162161 {
163- case Tensor v : ignoreDispose [ i ] = true ; feeds [ i ++ ] = new KeyValuePair < TF_Output , Tensor > ( tensor . _as_tf_output ( ) , v ) ; break ;
162+ case Tensor v : feeds [ i ++ ] = new KeyValuePair < TF_Output , Tensor > ( tensor . _as_tf_output ( ) , v ) ; break ;
164163 case NDArray v : feeds [ i ++ ] = new KeyValuePair < TF_Output , Tensor > ( tensor . _as_tf_output ( ) , new Tensor ( v , tensor . dtype ) ) ; break ;
164+ case IntPtr v : feeds [ i ++ ] = new KeyValuePair < TF_Output , Tensor > ( tensor . _as_tf_output ( ) , new Tensor ( v ) ) ; break ;
165165#if _REGEN
166166 % types = [ "sbyte" , "byte" , "short" , "ushort" , "int" , "uint" , "long" , "ulong" , "float" , "double" , "Complex" ]
167167 % foreach types%
@@ -194,7 +194,6 @@ private NDArray[] _do_run(List<Operation> target_list, List<Tensor> fetch_list,
194194#endif
195195 case bool v : feeds [ i ++ ] = new KeyValuePair < TF_Output , Tensor > ( tensor . _as_tf_output ( ) , new Tensor ( ( byte ) ( v ? 1 : 0 ) , TF_DataType . TF_BOOL ) ) ; break ;
196196 case string v : feeds [ i ++ ] = new KeyValuePair < TF_Output , Tensor > ( tensor . _as_tf_output ( ) , new Tensor ( v ) ) ; break ;
197- case IntPtr v : feeds [ i ++ ] = new KeyValuePair < TF_Output , Tensor > ( tensor . _as_tf_output ( ) , new Tensor ( v ) ) ; break ;
198197 default :
199198 throw new NotImplementedException ( $ "feed_dict data type { x . Value ? . GetType ( ) . Name ?? "<null>" } ") ;
200199 }
@@ -203,18 +202,7 @@ private NDArray[] _do_run(List<Operation> target_list, List<Tensor> fetch_list,
203202
204203 var fetches = fetch_list . Select ( x => x . _as_tf_output ( ) ) . ToArray ( ) ;
205204 //var targets = target_list;
206- try
207- {
208- return _call_tf_sessionrun ( feeds , fetches , target_list ) ;
209- } finally
210- {
211- for ( var idx = 0 ; idx < feeds . Length ; idx ++ )
212- {
213- if ( ignoreDispose [ idx ] )
214- continue ;
215- feeds [ idx ] . Value . Dispose ( ) ;
216- }
217- }
205+ return _call_tf_sessionrun ( feeds , fetches , target_list ) ;
218206 }
219207
220208 private unsafe NDArray [ ] _call_tf_sessionrun ( KeyValuePair < TF_Output , Tensor > [ ] feed_dict , TF_Output [ ] fetch_list , List < Operation > target_list )
0 commit comments