66
77namespace Tensorflow
88{
9- public class Operation
9+ public partial class Operation
1010 {
1111 private readonly IntPtr _handle ;
1212
@@ -20,112 +20,6 @@ public class Operation
2020 public string OpType => c_api . StringPiece ( c_api . TF_OperationOpType ( _handle ) ) ;
2121 public string Device => c_api . StringPiece ( c_api . TF_OperationDevice ( _handle ) ) ;
2222
23- public int NumOutputs => c_api . TF_OperationNumOutputs ( _handle ) ;
24- public TF_DataType OutputType ( int index ) => c_api . TF_OperationOutputType ( new TF_Output ( _handle , index ) ) ;
25- public int OutputListLength ( string name ) => c_api . TF_OperationOutputListLength ( _handle , name , status ) ;
26-
27- public TF_Output Input ( int index ) => c_api . TF_OperationInput ( new TF_Input ( _handle , index ) ) ;
28- public TF_DataType InputType ( int index ) => c_api . TF_OperationInputType ( new TF_Input ( _handle , index ) ) ;
29- public int InputListLength ( string name ) => c_api . TF_OperationInputListLength ( _handle , name , status ) ;
30- public int NumInputs => c_api . TF_OperationNumInputs ( _handle ) ;
31-
32- public int OutputNumConsumers ( int index ) => c_api . TF_OperationOutputNumConsumers ( new TF_Output ( _handle , index ) ) ;
33- public unsafe TF_Input [ ] OutputConsumers ( int index , int max_consumers )
34- {
35- int size = Marshal . SizeOf < TF_Input > ( ) ;
36- var handle = Marshal . AllocHGlobal ( size ) ;
37- int num = c_api . TF_OperationOutputConsumers ( new TF_Output ( _handle , index ) , handle , max_consumers ) ;
38- var consumers = new TF_Input [ num ] ;
39- for ( int i = 0 ; i < num ; i ++ )
40- {
41- consumers [ i ] = Marshal . PtrToStructure < TF_Input > ( handle + i * size ) ;
42- }
43-
44- return consumers ;
45- }
46-
47- public int NumControlInputs => c_api . TF_OperationNumControlInputs ( _handle ) ;
48-
49- public unsafe Operation [ ] GetControlInputs ( )
50- {
51- var control_inputs = new Operation [ NumControlInputs ] ;
52-
53- if ( NumControlInputs > 0 )
54- {
55- IntPtr control_input_handle = Marshal . AllocHGlobal ( Marshal . SizeOf < IntPtr > ( ) * NumControlInputs ) ;
56- c_api . TF_OperationGetControlInputs ( _handle , control_input_handle , NumControlInputs ) ;
57- for ( int i = 0 ; i < NumControlInputs ; i ++ )
58- {
59- var handle = control_input_handle + Marshal . SizeOf < IntPtr > ( ) * i ;
60- control_inputs [ i ] = new Operation ( * ( IntPtr * ) handle ) ;
61- }
62- }
63-
64- return control_inputs;
65- }
66-
67- public int NumControlOutputs => c_api . TF_OperationNumControlOutputs ( _handle ) ;
68-
69- public unsafe Operation [ ] GetControlOutputs ( )
70- {
71- var control_outputs = new Operation [ NumControlOutputs ] ;
72-
73- if ( NumControlOutputs > 0 )
74- {
75- IntPtr control_output_handle = Marshal . AllocHGlobal ( Marshal . SizeOf < IntPtr > ( ) * NumControlOutputs ) ;
76- c_api . TF_OperationGetControlOutputs ( _handle , control_output_handle , NumControlInputs ) ;
77- for ( int i = 0 ; i < NumControlInputs ; i ++ )
78- {
79- var handle = control_output_handle + Marshal . SizeOf < IntPtr > ( ) * i ;
80- control_outputs [ i ] = new Operation ( * ( IntPtr * ) handle ) ;
81- }
82- }
83-
84- return control_outputs;
85- }
86-
87- private Tensor [ ] _outputs;
88- public Tensor[ ] outputs
89- {
90- get
91- {
92- if ( _outputs == null )
93- {
94- _outputs = new Tensor [ NumOutputs ] ;
95-
96- for ( int i = 0 ; i < NumOutputs ; i++ )
97- _outputs[ i ] = new Tensor ( this , i , OutputType ( i ) ) ;
98- }
99-
100- return _outputs;
101- }
102- }
103-
104- private InputList _inputs;
105- public InputList inputs
106- {
107- get
108- {
109- if ( _inputs == null )
110- {
111- var retval = new Tensor [ NumInputs ] ;
112-
113- for ( int i = 0 ; i < NumInputs ; i++ )
114- {
115- var tf_outpus = Input( i ) ;
116- var op = new Operation ( tf_outpus . oper ) ;
117- retval [ i ] = op . outputs [ tf_outpus . index ] ;
118- }
119-
120- _inputs = new InputList ( retval ) ;
121- }
122-
123- return _inputs;
124- }
125- }
126-
127- private TF_DataType [ ] _input_types => _inputs . _inputs . Select ( x => x . dtype ) . ToArray ( ) ;
128-
12923 private NodeDef _node_def ;
13024 public NodeDef node_def
13125 {
0 commit comments