Skip to content

Commit 7bf8422

Browse files
committed
Better docs
1 parent e060acd commit 7bf8422

13 files changed

Lines changed: 10787 additions & 10572 deletions

File tree

OpGenerator/OpGenerator.cs

Lines changed: 41 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -271,38 +271,55 @@ string FillArguments (OpDef def)
271271
return sb.ToString ();
272272
}
273273

274-
string Quote (string input)
275-
{
276-
var p = input.IndexOf ('`');
277-
if (p == -1)
278-
return input;
279-
var res = new StringBuilder ();
280-
bool open = true;
281-
foreach (var c in input) {
282-
if (c == '`') {
283-
res.Append (open ? "<code>" : "</code>");
284-
open = !open;
285-
} else
286-
res.Append (c);
287-
}
288-
return res.ToString ();
289-
}
290-
291274
void Comment (string text)
292275
{
293276
if (text == null || text == "")
294277
return;
295278
var lines = text.Split ('\n');
296-
bool open = true;
279+
var open = true;
280+
281+
string Quote (string input)
282+
{
283+
var p = input.IndexOf ('`');
284+
if (p == -1)
285+
return input;
286+
var res = new StringBuilder ();
287+
foreach (var c in input) {
288+
if (c == '`') {
289+
res.Append (open ? "<c>" : "</c>");
290+
open = !open;
291+
} else
292+
res.Append (c);
293+
}
294+
return res.ToString ();
295+
}
296+
297+
bool blockOpen = true;
297298
foreach (var line in lines) {
299+
if (line.IndexOf ("in image height coordinates.") != -1) {
300+
Console.WriteLine ("Hello");
301+
}
302+
298303
var line2 = line.Trim ().Replace ("<", "&lt;").Replace (">", "&gt;").Replace ("&", "&amp;");
299304

300-
if (line == "```") {
301-
p ("/// " + (open ? "<code>" : "</code>"));
302-
open = !open;
303-
} else {
304-
p ($"/// {Quote (line2)}");
305-
}
305+
if (line2.StartsWith ("```")){
306+
p ("/// " + (blockOpen ? "<code>" : "</code>"));
307+
blockOpen = !blockOpen;
308+
if (line2 == "```python" || line2 == "```c++" || line2 == "```")
309+
continue;
310+
// Handle some broken comments in the api specs, they sometimes missuse the
311+
312+
line2 = line2.Substring (3);
313+
if (line2.EndsWith ("```")){
314+
var line3 = line2.Substring (0, line2.Length - 3);
315+
p ($"/// {Quote (line3)}");
316+
p ("/// " + (blockOpen ? "<code>" : "</code>"));
317+
blockOpen = !blockOpen;
318+
continue;
319+
}
320+
}
321+
p ($"/// {Quote (line2)}");
322+
306323
}
307324
}
308325

TensorFlowSharp/Operations.g.cs

Lines changed: 2690 additions & 2675 deletions
Large diffs are not rendered by default.

TensorFlowSharp/Tensorflow.cs

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,10 @@ public int InputListLength (string argName, TFStatus status = null)
19631963
// extern int TF_OperationNumControlInputs (TF_Operation *oper);
19641964
[DllImport (NativeBinding.TensorFlowLibrary)]
19651965
static extern unsafe int TF_OperationNumControlInputs (TF_Operation oper);
1966+
/// <summary>
1967+
/// Gets the number of control inputs oto an operation
1968+
/// </summary>
1969+
/// <value>The number control inputs.</value>
19661970
public int NumControlInputs => TF_OperationNumControlInputs (handle);
19671971

19681972
// extern int TF_OperationGetControlInputs (TF_Operation *oper, TF_Operation **control_inputs, int max_control_inputs);
@@ -1972,13 +1976,21 @@ public int InputListLength (string argName, TFStatus status = null)
19721976
// extern int TF_OperationNumControlOutputs (TF_Operation *oper);
19731977
[DllImport (NativeBinding.TensorFlowLibrary)]
19741978
static extern unsafe int TF_OperationNumControlOutputs (TF_Operation oper);
1979+
1980+
/// <summary>
1981+
/// Gets the number of operations that have this operation as a control input.
1982+
/// </summary>
19751983
public int NumControlOutputs => TF_OperationNumControlOutputs (handle);
19761984

19771985
// extern int TF_OperationGetControlOutputs (TF_Operation *oper, TF_Operation **control_outputs, int max_control_outputs);
19781986
[DllImport (NativeBinding.TensorFlowLibrary)]
19791987
static extern unsafe int TF_OperationGetControlOutputs (TF_Operation oper, [Out] [MarshalAs (UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr [] control_outputs, int max_control_outputs);
19801988

1981-
TFOperation [] ControlOutputs {
1989+
/// <summary>
1990+
/// Get the list of operations that have this operation as a control input.
1991+
/// </summary>
1992+
/// <value>The control outputs.</value>
1993+
public TFOperation [] ControlOutputs {
19821994
get {
19831995
var n = NumControlOutputs;
19841996
var arr = new IntPtr [n];
@@ -2130,24 +2142,55 @@ public TFOutput this [int idx] {
21302142
}
21312143
}
21322144

2145+
2146+
/// <summary>
2147+
/// Device type
2148+
/// </summary>
21332149
public enum DeviceType
21342150
{
2135-
CPU, GPU, TPU
2151+
/// <summary>
2152+
/// The device is the Central Processing Unit (CPU)
2153+
/// </summary>
2154+
CPU,
2155+
2156+
/// <summary>
2157+
/// The device is a Graphics Processing Unit (GPU)
2158+
/// </summary>
2159+
GPU,
2160+
2161+
/// <summary>
2162+
/// The device is a Tensor Processing Unit (TPU)
2163+
/// </summary>
2164+
TPU
21362165
}
21372166

2167+
/// <summary>
2168+
/// Describes the device attributes
2169+
/// </summary>
21382170
public class DeviceAttributes
21392171
{
2140-
public DeviceAttributes (string name, DeviceType deviceType, long memoryLimitBytes)
2172+
internal DeviceAttributes (string name, DeviceType deviceType, long memoryLimitBytes)
21412173
{
21422174
Name = name;
21432175
DeviceType = deviceType;
21442176
MemoryLimitBytes = memoryLimitBytes;
21452177
}
2146-
2178+
2179+
/// <summary>
2180+
/// The full name of the device (e.g. /job:worker/replica:0/...)
2181+
/// </summary>
21472182
public string Name { get; private set; }
21482183

2184+
/// <summary>
2185+
/// Gets the type of the device.
2186+
/// </summary>
2187+
/// <value>The type of the device.</value>
21492188
public DeviceType DeviceType { get; private set; }
21502189

2190+
/// <summary>
2191+
/// The amount of memory associated with a given device.
2192+
/// </summary>
2193+
/// <value>The memory limit bytes.</value>
21512194
public long MemoryLimitBytes { get; private set; }
21522195
}
21532196

@@ -2429,6 +2472,7 @@ public TFSession (TFStatus status = null) : this (new TFGraph (), status)
24292472
/// <summary>
24302473
/// Lists available devices in this session.
24312474
/// </summary>
2475+
/// <param name="status">Status buffer, if specified a status code will be left here, if not specified, a <see cref="T:TensorFlow.TFException"/> exception is raised if there is an error.</param>
24322476
public IEnumerable<DeviceAttributes> ListDevices(TFStatus status = null)
24332477
{
24342478
var cstatus = TFStatus.Setup (status);
@@ -2511,6 +2555,10 @@ public void CloseSession (TFStatus status = null)
25112555
[DllImport (NativeBinding.TensorFlowLibrary)]
25122556
static extern unsafe void TF_DeleteSession (TF_Session session, TF_Status status);
25132557

2558+
/// <summary>
2559+
/// Deletes the session.
2560+
/// </summary>
2561+
/// <param name="status">Status.</param>
25142562
public void DeleteSession (TFStatus status = null)
25152563
{
25162564
if (handle == IntPtr.Zero)

0 commit comments

Comments
 (0)