@@ -29,48 +29,48 @@ namespace Tensorflow.Contexts
29
29
/// </summary>
30
30
public sealed partial class Context
31
31
{
32
- // [DebuggerStepThrough]
33
- public Tensors ExecuteOp ( string OpType , string Name , ExecuteOpArgs args )
32
+ Tensors ExecGraphAction ( string OpType , string Name , ExecuteOpArgs args )
34
33
{
35
- Func < Tensors > graphAction = ( ) =>
34
+ var keywords = new Dictionary < string , object > ( ) ;
35
+ if ( args . OpInputArgs != null )
36
36
{
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
+ }
43
40
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
+ }
49
46
50
- return tf . OpDefLib . _apply_op_helper ( OpType , Name , keywords ) . outputs ;
51
- } ;
47
+ return tf . OpDefLib . _apply_op_helper ( OpType , Name , keywords ) . outputs ;
48
+ }
52
49
53
- Func < Tensors > eagerAction = ( ) =>
50
+ Tensors ExecEagerAction ( string OpType , string Name , ExecuteOpArgs args )
51
+ {
52
+ var opExecInfo = new FastPathOpExecInfo ( OpType , Name , args . OpInputArgs )
54
53
{
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
60
55
} ;
56
+ return tf . Runner . TFE_FastPathExecute ( opExecInfo ) ;
57
+ }
61
58
59
+ // [DebuggerStepThrough]
60
+ public Tensors ExecuteOp ( string opType , string name , ExecuteOpArgs args )
61
+ {
62
62
if ( tf . Context . has_graph_arg ( args . OpInputArgs ) )
63
63
{
64
64
if ( executing_eagerly ( ) )
65
65
{
66
66
graph_mode ( ) ;
67
- var result = graphAction ( ) ;
67
+ var result = ExecGraphAction ( opType , name , args ) ;
68
68
restore_mode ( ) ;
69
69
return result ;
70
70
}
71
71
else
72
72
{
73
- var result = graphAction ( ) ;
73
+ var result = ExecGraphAction ( opType , name , args ) ;
74
74
if ( tf . Runner . MustRecordGradient ( ) )
75
75
{
76
76
var op = result [ 0 ] . op ;
@@ -92,14 +92,14 @@ public Tensors ExecuteOp(string OpType, string Name, ExecuteOpArgs args)
92
92
args1 [ i + 1 ] = arg . Value ;
93
93
i += 2 ;
94
94
}
95
- tf . Runner . RecordGradient ( OpType , op . inputs , args1 , op . outputs ) ;
95
+ tf . Runner . RecordGradient ( opType , op . inputs , args1 , op . outputs ) ;
96
96
}
97
97
return result ;
98
98
}
99
99
}
100
100
else
101
101
{
102
- return eagerAction ( ) ;
102
+ return ExecEagerAction ( opType , name , args ) ;
103
103
}
104
104
}
105
105
}
0 commit comments