@@ -15,7 +15,9 @@ namespace Tensorflow.Eager
1515 /// </summary>
1616 public partial class EagerRunner
1717 {
18- UnorderedMap < Context , SafeOpHandle > thread_local_eager_operation_map = new UnorderedMap < Context , SafeOpHandle > ( ) ;
18+ UnorderedMap < string , SafeOpHandle > thread_local_eager_operation_map = new UnorderedMap < string , SafeOpHandle > ( ) ;
19+ public void ClearEagerOperationMap ( )
20+ => thread_local_eager_operation_map . Clear ( ) ;
1921
2022 public Tensor [ ] TFE_FastPathExecute ( FastPathOpExecInfo op_exec_info )
2123 {
@@ -31,7 +33,7 @@ public Tensor[] TFE_FastPathExecute(FastPathOpExecInfo op_exec_info)
3133 op_exec_info . run_callbacks = op_exec_info . run_gradient_callback || op_exec_info . run_post_exec_callbacks ;
3234
3335 var status = tf . Status ;
34- using var op = GetOp ( op_exec_info . ctx , op_exec_info . op_name , status ) ;
36+ var op = GetOp ( op_exec_info . ctx , op_exec_info . op_name , status ) ;
3537
3638 var op_def = tf . get_default_graph ( ) . GetOpDef ( op_exec_info . op_name ) ;
3739
@@ -56,8 +58,8 @@ public Tensor[] TFE_FastPathExecute(FastPathOpExecInfo op_exec_info)
5658 }
5759 }
5860
59- c_api . TFE_OpSetDevice ( op , op_exec_info . device_name , status . Handle ) ;
60- status . Check ( true ) ;
61+ // c_api.TFE_OpSetDevice(op, op_exec_info.device_name, status.Handle);
62+ // status.Check(true);
6163
6264 // Add inferred attrs and inputs.
6365 for ( int i = 0 ; i < op_def . InputArg . Count ; i ++ )
@@ -145,7 +147,6 @@ public Tensor[] TFE_FastPathExecute(FastPathOpExecInfo op_exec_info)
145147
146148 var flat_result = retVals . Select ( x => new EagerTensor ( x ) ) . ToArray ( ) ;
147149
148-
149150 if ( op_exec_info . run_callbacks )
150151 {
151152 RunCallbacks ( op_exec_info ,
@@ -158,19 +159,19 @@ public Tensor[] TFE_FastPathExecute(FastPathOpExecInfo op_exec_info)
158159
159160 SafeOpHandle GetOp ( Context ctx , string op_or_function_name , Status status )
160161 {
161- /* if (thread_local_eager_operation_map.find(ctx , out var op))
162+ if ( thread_local_eager_operation_map . find ( op_or_function_name , out var op ) )
162163 c_api . TFE_OpReset ( op , op_or_function_name , ctx . DeviceName , status . Handle ) ;
163164 else
164165 {
165166 op = c_api . TFE_NewOp ( ctx . Handle , op_or_function_name , status . Handle ) ;
166- thread_local_eager_operation_map[ctx ] = op;
167+ thread_local_eager_operation_map [ op_or_function_name ] = op ;
167168 }
168169
169- status.Check(true);
170- return op;*/
171- var op = c_api . TFE_NewOp ( ctx . Handle , op_or_function_name , status . Handle ) ;
172170 status . Check ( true ) ;
173171 return op ;
172+ /*var op = c_api.TFE_NewOp(ctx.Handle, op_or_function_name, status.Handle);
173+ status.Check(true);
174+ return op;*/
174175 }
175176
176177 bool HasAccumulator ( )
@@ -268,16 +269,7 @@ void SetOpAttrWithDefaults(Context ctx, SafeOpHandle op, AttrDef attr,
268269
269270 if ( attr_value == null )
270271 {
271- if ( is_list != 0 )
272- #pragma warning disable CS0642 // Possible mistaken empty statement
273- ;
274- #pragma warning restore CS0642 // Possible mistaken empty statement
275- //SetOpAttrListDefault
276- else
277- #pragma warning disable CS0642 // Possible mistaken empty statement
278- ;
279- #pragma warning restore CS0642 // Possible mistaken empty statement
280- //SetOpAttrScalarDefault
272+
281273 }
282274 else
283275 {
0 commit comments