@@ -29,48 +29,48 @@ namespace Tensorflow.Contexts
2929 /// </summary>
3030 public sealed partial class Context
3131 {
32- // [DebuggerStepThrough]
33- public Tensors ExecuteOp ( string OpType , string Name , ExecuteOpArgs args )
32+ Tensors ExecGraphAction ( string OpType , string Name , ExecuteOpArgs args )
3433 {
35- Func < Tensors > graphAction = ( ) =>
34+ var keywords = new Dictionary < string , object > ( ) ;
35+ if ( args . OpInputArgs != null )
3636 {
37- var keywords = new Dictionary < string , object > ( ) ;
38- if ( args . OpInputArgs != null )
39- {
40- foreach ( var ( i , input ) in enumerate ( args . OpInputArgs ) )
41- keywords [ $ "input_{ i } "] = input ;
42- }
37+ foreach ( var ( i , input ) in enumerate ( args . OpInputArgs ) )
38+ keywords [ $ "input_{ i } "] = input ;
39+ }
4340
44- if ( args . OpAttrs != null )
45- {
46- foreach ( var attr in args . OpAttrs )
47- keywords [ attr . Key ] = attr . Value ;
48- }
41+ if ( args . OpAttrs != null )
42+ {
43+ foreach ( var attr in args . OpAttrs )
44+ keywords [ attr . Key ] = attr . Value ;
45+ }
4946
50- return tf . OpDefLib . _apply_op_helper ( OpType , Name , keywords ) . outputs ;
51- } ;
47+ return tf . OpDefLib . _apply_op_helper ( OpType , Name , keywords ) . outputs ;
48+ }
5249
53- Func < Tensors > eagerAction = ( ) =>
50+ Tensors ExecEagerAction ( string OpType , string Name , ExecuteOpArgs args )
51+ {
52+ var opExecInfo = new FastPathOpExecInfo ( OpType , Name , args . OpInputArgs )
5453 {
55- var opExecInfo = new FastPathOpExecInfo ( OpType , Name , args . OpInputArgs )
56- {
57- attrs = args . OpAttrs
58- } ;
59- return tf . Runner . TFE_FastPathExecute ( opExecInfo ) ;
54+ attrs = args . OpAttrs
6055 } ;
56+ return tf . Runner . TFE_FastPathExecute ( opExecInfo ) ;
57+ }
6158
59+ // [DebuggerStepThrough]
60+ public Tensors ExecuteOp ( string opType , string name , ExecuteOpArgs args )
61+ {
6262 if ( tf . Context . has_graph_arg ( args . OpInputArgs ) )
6363 {
6464 if ( executing_eagerly ( ) )
6565 {
6666 graph_mode ( ) ;
67- var result = graphAction ( ) ;
67+ var result = ExecGraphAction ( opType , name , args ) ;
6868 restore_mode ( ) ;
6969 return result ;
7070 }
7171 else
7272 {
73- var result = graphAction ( ) ;
73+ var result = ExecGraphAction ( opType , name , args ) ;
7474 if ( tf . Runner . MustRecordGradient ( ) )
7575 {
7676 var op = result [ 0 ] . op ;
@@ -92,14 +92,14 @@ public Tensors ExecuteOp(string OpType, string Name, ExecuteOpArgs args)
9292 args1 [ i + 1 ] = arg . Value ;
9393 i += 2 ;
9494 }
95- tf . Runner . RecordGradient ( OpType , op . inputs , args1 , op . outputs ) ;
95+ tf . Runner . RecordGradient ( opType , op . inputs , args1 , op . outputs ) ;
9696 }
9797 return result ;
9898 }
9999 }
100100 else
101101 {
102- return eagerAction ( ) ;
102+ return ExecEagerAction ( opType , name , args ) ;
103103 }
104104 }
105105 }
0 commit comments