@@ -152,16 +152,16 @@ private NDArray[] _do_run(List<Operation> target_list, List<Tensor> fetch_list,
152
152
{
153
153
154
154
var feeds = new KeyValuePair < TF_Output , Tensor > [ feed_dict . Count ] ;
155
- var ignoreDispose = new bool [ feed_dict . Count ] ;
156
155
int i = 0 ;
157
156
foreach ( var x in feed_dict )
158
157
{
159
158
if ( x . Key is Tensor tensor )
160
159
{
161
160
switch ( x . Value )
162
161
{
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 ;
164
163
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 ;
165
165
#if _REGEN
166
166
% types = [ "sbyte" , "byte" , "short" , "ushort" , "int" , "uint" , "long" , "ulong" , "float" , "double" , "Complex" ]
167
167
% foreach types%
@@ -194,7 +194,6 @@ private NDArray[] _do_run(List<Operation> target_list, List<Tensor> fetch_list,
194
194
#endif
195
195
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 ;
196
196
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 ;
198
197
default :
199
198
throw new NotImplementedException ( $ "feed_dict data type { x . Value ? . GetType ( ) . Name ?? "<null>" } ") ;
200
199
}
@@ -203,18 +202,7 @@ private NDArray[] _do_run(List<Operation> target_list, List<Tensor> fetch_list,
203
202
204
203
var fetches = fetch_list . Select ( x => x . _as_tf_output ( ) ) . ToArray ( ) ;
205
204
//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 ) ;
218
206
}
219
207
220
208
private unsafe NDArray [ ] _call_tf_sessionrun ( KeyValuePair < TF_Output , Tensor > [ ] feed_dict , TF_Output [ ] fetch_list , List < Operation > target_list )
0 commit comments