forked from SciSharp/TensorFlow.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc_api.ops.cs
More file actions
212 lines (182 loc) · 9.08 KB
/
c_api.ops.cs
File metadata and controls
212 lines (182 loc) · 9.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*****************************************************************************
Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
******************************************************************************/
using System;
using System.Runtime.InteropServices;
namespace Tensorflow
{
public partial class c_api
{
/// <summary>
/// Request that `desc` be co-located on the device where `op`
/// is placed.
///
/// Use of this is discouraged since the implementation of device placement is
/// subject to change. Primarily intended for internal libraries
/// </summary>
/// <param name="desc"></param>
/// <param name="op"></param>
[DllImport(TensorFlowLibName)]
public static extern void TF_ColocateWith(IntPtr desc, IntPtr op);
/// <summary>
/// Get the OpList of all OpDefs defined in this address space.
/// </summary>
/// <returns></returns>
[DllImport(TensorFlowLibName)]
public static extern IntPtr TF_GetAllOpList();
/// <summary>
/// For inputs that take a single tensor.
/// </summary>
/// <param name="desc">TF_OperationDescription*</param>
/// <param name="input">TF_Output</param>
[DllImport(TensorFlowLibName)]
public static extern void TF_AddInput(IntPtr desc, TF_Output input);
/// <summary>
/// Call once per control input to `desc`.
/// </summary>
/// <param name="desc">TF_OperationDescription*</param>
/// <param name="input">TF_Operation*</param>
[DllImport(TensorFlowLibName)]
public static extern void TF_AddControlInput(IntPtr desc, IntPtr input);
/// <summary>
///
/// </summary>
/// <param name="graph">TF_Graph*</param>
/// <param name="op">TF_Operation*</param>
/// <param name="input">TF_Operation*</param>
[DllImport(TensorFlowLibName)]
public static extern void AddControlInput(IntPtr graph, IntPtr op, IntPtr input);
/// <summary>
///
/// </summary>
/// <param name="graph">TF_Graph*</param>
/// <param name="op">TF_Operation*</param>
[DllImport(TensorFlowLibName)]
public static extern void RemoveAllControlInputs(IntPtr graph, IntPtr op);
/// <summary>
/// For inputs that take a list of tensors.
/// inputs must point to TF_Output[num_inputs].
/// </summary>
/// <param name="desc"></param>
/// <param name="inputs"></param>
[DllImport(TensorFlowLibName)]
public static extern void TF_AddInputList(IntPtr desc, TF_Output[] inputs, int num_inputs);
[DllImport(TensorFlowLibName)]
public static extern IntPtr TF_FinishOperation(IntPtr desc, IntPtr status);
/// <summary>
/// Operation will only be added to *graph when TF_FinishOperation() is
/// called (assuming TF_FinishOperation() does not return an error).
/// *graph must not be deleted until after TF_FinishOperation() is
/// called.
/// </summary>
/// <param name="graph">TF_Graph*</param>
/// <param name="opType">const char*</param>
/// <param name="oper_name">const char*</param>
/// <returns>TF_OperationDescription*</returns>
[DllImport(TensorFlowLibName)]
public static extern IntPtr TF_NewOperation(IntPtr graph, string opType, string oper_name);
[DllImport(TensorFlowLibName)]
public static extern IntPtr TF_OperationDevice(IntPtr oper);
/// <summary>
/// Get list of all control inputs to an operation. `control_inputs` must
/// point to an array of length `max_control_inputs` (ideally set to
/// TF_OperationNumControlInputs(oper)). Returns the number of control
/// inputs (should match TF_OperationNumControlInputs(oper)).
/// </summary>
/// <param name="oper">TF_Operation*</param>
/// <param name="control_inputs">TF_Operation**</param>
/// <param name="max_control_inputs"></param>
/// <returns></returns>
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationGetControlInputs(IntPtr oper, IntPtr control_inputs, int max_control_inputs);
/// <summary>
/// Get the list of operations that have `*oper` as a control input.
/// `control_outputs` must point to an array of length at least
/// `max_control_outputs` (ideally set to
/// TF_OperationNumControlOutputs(oper)). Beware that a concurrent
/// modification of the graph can increase the number of control
/// outputs. Returns the number of control outputs (should match
/// TF_OperationNumControlOutputs(oper)).
/// </summary>
/// <param name="oper">TF_Operation*</param>
/// <param name="control_outputs">TF_Operation**</param>
/// <param name="max_control_outputs"></param>
/// <returns></returns>
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationGetControlOutputs(IntPtr oper, IntPtr control_outputs, int max_control_outputs);
/// <summary>
/// TF_Output producer = TF_OperationInput(consumer);
/// There is an edge from producer.oper's output (given by
/// producer.index) to consumer.oper's input (given by consumer.index).
/// </summary>
/// <param name="oper_in"></param>
/// <returns></returns>
[DllImport(TensorFlowLibName)]
public static extern TF_Output TF_OperationInput(TF_Input oper_in);
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationInputListLength(IntPtr oper, string arg_name, IntPtr status);
[DllImport(TensorFlowLibName)]
public static extern TF_DataType TF_OperationInputType(TF_Input oper_in);
[DllImport(TensorFlowLibName)]
public static extern IntPtr TF_OperationName(IntPtr oper);
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationNumInputs(IntPtr oper);
[DllImport(TensorFlowLibName)]
public static extern IntPtr TF_OperationOpType(IntPtr oper);
/// <summary>
/// Get the number of control inputs to an operation.
/// </summary>
/// <param name="oper"></param>
/// <returns></returns>
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationNumControlInputs(IntPtr oper);
/// <summary>
/// Get the number of operations that have `*oper` as a control input.
/// </summary>
/// <param name="oper"></param>
/// <returns></returns>
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationNumControlOutputs(IntPtr oper);
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationNumOutputs(IntPtr oper);
/// <summary>
/// Get the number of current consumers of a specific output of an
/// operation. Note that this number can change when new operations
/// are added to the graph.
/// </summary>
/// <param name="oper_out"></param>
/// <returns></returns>
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationOutputNumConsumers(TF_Output oper_out);
/// <summary>
/// Get list of all current consumers of a specific output of an
/// operation. `consumers` must point to an array of length at least
/// `max_consumers` (ideally set to
/// TF_OperationOutputNumConsumers(oper_out)). Beware that a concurrent
/// modification of the graph can increase the number of consumers of
/// an operation. Returns the number of output consumers (should match
/// TF_OperationOutputNumConsumers(oper_out)).
/// </summary>
/// <param name="oper_out">TF_Output</param>
/// <param name="consumers">TF_Input*</param>
/// <param name="max_consumers">int</param>
/// <returns></returns>
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationOutputConsumers(TF_Output oper_out, IntPtr consumers, int max_consumers);
[DllImport(TensorFlowLibName)]
public static extern TF_DataType TF_OperationOutputType(TF_Output oper_out);
[DllImport(TensorFlowLibName)]
public static extern void TF_OperationToNodeDef(IntPtr oper, IntPtr buffer, IntPtr status);
[DllImport(TensorFlowLibName)]
public static extern int TF_OperationOutputListLength(IntPtr oper, string arg_name, IntPtr status);
}
}