Skip to content

Commit 583318e

Browse files
committed
Documentation updates
1 parent 1bed2e1 commit 583318e

File tree

1 file changed

+123
-7
lines changed

1 file changed

+123
-7
lines changed

TensorFlowSharp/Tensorflow.cs

Lines changed: 123 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ internal static void ObjectDisposedException ()
193193
/// TensorFlow Exception
194194
/// </summary>
195195
public class TFException : Exception {
196+
/// <summary>
197+
/// Initializes a new instance of the <see cref="T:TensorFlow.TFException"/> class with a message.
198+
/// </summary>
199+
/// <param name="message">Message.</param>
196200
public TFException (string message) : base (message) { }
197201
}
198202

@@ -217,6 +221,15 @@ public class TFStatus : TFDisposable
217221
[DllImport (NativeBinding.TensorFlowLibrary)]
218222
internal static extern unsafe TF_Status TF_NewStatus ();
219223

224+
/// <summary>
225+
/// Per-thread global status that you can use if you do not need to create a new instance of this object.
226+
/// </summary>
227+
/// <remarks>
228+
/// This is provided as a convenience for APIs that take a TFStatus. While the TFStatus is usually an
229+
/// optional parameter, when it is made optional, API calls that fail raise an exception. Use this
230+
/// property to pass a TFStatus without having to allocate a new one. The problem with this of course
231+
/// is that you risk having multiple parts of your code override this thread-global variable.
232+
/// </remarks>
220233
[ThreadStatic] public static TFStatus Default = new TFStatus ();
221234

222235
/// <summary>
@@ -354,6 +367,9 @@ internal class TFString
354367
internal static extern size_t TF_StringEncodedSize (size_t len);
355368
}
356369

370+
/// <summary>
371+
/// The session options object holds configuration options that you want to use during your session, like the TensorFlow target or the configuration.
372+
/// </summary>
357373
public class TFSessionOptions : TFDisposable
358374
{
359375
// extern TF_SessionOptions * TF_NewSessionOptions ();
@@ -373,6 +389,13 @@ internal override void NativeDispose (IntPtr handle)
373389
// extern void TF_SetTarget (TF_SessionOptions *options, const char *target);
374390
[DllImport (NativeBinding.TensorFlowLibrary)]
375391
static extern unsafe void TF_SetTarget (TF_SessionOptions options, string target);
392+
393+
/// <summary>
394+
/// Sets the target in options.
395+
/// </summary>
396+
/// <param name="target">target can be empty, a single entry, or a comma separated list of entries.
397+
/// Each entry is in one of the following formats: "local", ip:port, host:port.</param>
398+
///
376399
public void SetTarget (string target)
377400
{
378401
if (handle == IntPtr.Zero)
@@ -385,7 +408,15 @@ public void SetTarget (string target)
385408
[DllImport (NativeBinding.TensorFlowLibrary)]
386409
static extern unsafe void TF_SetConfig (TF_SessionOptions options, IntPtr proto, size_t proto_len, TF_Status status);
387410

388-
411+
/// <summary>
412+
/// Sets the configuration information for the session.
413+
/// </summary>
414+
/// <param name="protoData">Serialized protocol buffer for the tensorflow.ConfigProto message.</param>
415+
/// <param name="length">Length of the buffer.</param>
416+
/// <param name="status">If config was not parsed successfully as a ConfigProto, the error is recorded here.</param>
417+
/// <remarks>
418+
/// The configuration option is a Protocol Buffer representing the tensorflow.ConfigProto
419+
/// </remarks>
389420
public void SetConfig (IntPtr protoData, int length, TFStatus status = null)
390421
{
391422
if (handle == IntPtr.Zero)
@@ -978,6 +1009,12 @@ internal TFScope (TFGraph container)
9781009
name = container.CurrentNameScope;
9791010
}
9801011

1012+
/// <summary>
1013+
/// Pops the name space to the previous namescope in use.
1014+
/// </summary>
1015+
/// <remarks>Call <see cref="Dispose"/> when you are finished using the <see cref="T:TensorFlow.TFScope"/>
1016+
/// to restore the previous name scope in use in the <see cref="T:TensorFlow.TFGraph"/>.
1017+
/// </remarks>
9811018
public void Dispose ()
9821019
{
9831020
container.CurrentNameScope = name;
@@ -997,7 +1034,8 @@ public void Dispose ()
9971034
/// nodes.
9981035
///
9991036
/// You create instances bound to a graph, add inputs, attributes and so on, and when you are done
1000-
/// you can call the FinishOperation method that will turn this TFOperationDesc into a <see cref="T:TensorFlow.TFOperation"/>.
1037+
/// you can call the <see cref="FinishOperation"/> method that will turn this TFOperationDesc
1038+
/// into a <see cref="T:TensorFlow.TFOperation"/>.
10011039
/// </remarks>
10021040
public class TFOperationDesc : TFDisposable
10031041
{
@@ -1408,6 +1446,11 @@ public TFOperationDesc SetAttr (string attrName, TFTensor [] tensor, TFStatus st
14081446
[DllImport (NativeBinding.TensorFlowLibrary)]
14091447
static extern unsafe TF_Operation TF_FinishOperation (TF_OperationDescription desc, TF_Status status);
14101448

1449+
/// <summary>
1450+
/// Turns the operation description into an actual operation in the graph.
1451+
/// </summary>
1452+
/// <returns>The operation on success, or null on error.</returns>
1453+
/// <param name="status">Optional status, on failure the operation is not added to the graph. If you pass null (the default), this operation throws on error conditions.</param>
14111454
public TFOperation FinishOperation (TFStatus status = null)
14121455
{
14131456
if (handle == IntPtr.Zero)
@@ -1417,6 +1460,8 @@ public TFOperation FinishOperation (TFStatus status = null)
14171460
cstatus.CheckMaybeRaise (status);
14181461
handle = IntPtr.Zero;
14191462
GC.SuppressFinalize (this);
1463+
if (status.Error)
1464+
return null;
14201465

14211466
return new TFOperation (graph, h);
14221467
}
@@ -1810,7 +1855,7 @@ public int NumReturnOutputs {
18101855
/// <param name="destination">References an operation that already exists in the graph being imported.</param>
18111856
/// <remarks>
18121857
/// Set any imported nodes with control input <paramref name="srcName"/> to have that input
1813-
/// replaced with <paramref name="dst"/>.
1858+
/// replaced with <paramref name="destination"/>.
18141859
/// </remarks>
18151860
public void RemapControlDependency (string srcName, TFOperation destination)
18161861
{
@@ -1829,8 +1874,17 @@ public void RemapControlDependency (string srcName, TFOperation destination)
18291874
/// </summary>
18301875
/// <remarks>
18311876
/// This creates a new context to execute a TFGraph. You can use the
1832-
/// constructo to create an empty session, or you can load an existing
1833-
/// model using the FromSAvedModel static method in this class.
1877+
/// constructor to create an empty session, or you can load an existing
1878+
/// model using the <see cref="FromSavedModel"/> static method in this class.
1879+
///
1880+
/// To execute operations with the graph, call the <see cref="GetRunner"/> method
1881+
/// which returns an object that you can use to build the operation by providing
1882+
/// the inputs, requesting the operations that you want to execute and the desired outputs.
1883+
///
1884+
/// The <see cref="GetRunner"/> method is a high-level helper function that wraps a
1885+
/// call to the <see cref="Run"/> method which just takes too many parameters that must
1886+
/// be kept in sync.
1887+
///
18341888
/// </remarks>
18351889
public class TFSession : TFDisposable
18361890
{
@@ -2082,7 +2136,7 @@ public Runner Fetch (TFOutput output)
20822136
/// Makes the Run method return the output of all the tensor referenced by outputs.
20832137
/// </summary>
20842138
/// <returns>The instance of runner, to allow chaining operations.</returns>
2085-
/// <param name="output">The outputs referencing a specified tensor.</param>
2139+
/// <param name="outputs">The outputs referencing a specified tensor.</param>
20862140
public Runner Fetch (params TFOutput [] outputs)
20872141
{
20882142
foreach (var output in outputs)
@@ -2094,7 +2148,7 @@ public Runner Fetch (params TFOutput [] outputs)
20942148
/// Makes the Run method return the output of all the tensor referenced by outputs.
20952149
/// </summary>
20962150
/// <returns>The instance of runner, to allow chaining operations.</returns>
2097-
/// <param name="output">The output sreferencing a specified tensor.</param>
2151+
/// <param name="outputs">The output sreferencing a specified tensor.</param>
20982152
public Runner Fetch (params string [] outputs)
20992153
{
21002154
foreach (var output in outputs)
@@ -2243,6 +2297,14 @@ void IDisposable.Dispose ()
22432297
}
22442298
}
22452299

2300+
/// <summary>
2301+
/// Prepares the session for a partial run.
2302+
/// </summary>
2303+
/// <returns>A token that can be used to call <see cref="PartialRun"/> repeatedly. To complete your partial run, you should call Dispose on the resulting method.</returns>
2304+
/// <param name="inputs">Inputs.</param>
2305+
/// <param name="outputs">Outputs.</param>
2306+
/// <param name="targetOpers">Target operations to run.</param>
2307+
/// <param name="status">Status.</param>
22462308
public PartialRunToken PartialRunSetup (TFOutput [] inputs, TFOutput [] outputs, TFOperation [] targetOpers, TFStatus status = null)
22472309
{
22482310
if (handle == IntPtr.Zero)
@@ -2362,24 +2424,78 @@ internal override void NativeDispose (IntPtr handle)
23622424
/// </remarks>
23632425
public enum TFDataType : uint
23642426
{
2427+
/// <summary>
2428+
/// Single precission floatint point, 32-bits (C# float)
2429+
/// </summary>
23652430
Float = 1,
2431+
/// <summary>
2432+
/// Double precission floatint point, 64-bits (C# double)
2433+
/// </summary>
23662434
Double = 2,
2435+
/// <summary>
2436+
/// 32-bit signed integers (C# int)
2437+
/// </summary>
23672438
Int32 = 3,
2439+
/// <summary>
2440+
/// 8 bit unsigned integers (C# byte)
2441+
/// </summary>
23682442
UInt8 = 4,
2443+
/// <summary>
2444+
/// 16-bit signed integers (C# short)
2445+
/// </summary>
23692446
Int16 = 5,
2447+
/// <summary>
2448+
/// 8-bit signed integers (C# sbyte)
2449+
/// </summary>
23702450
Int8 = 6,
2451+
/// <summary>
2452+
/// Binary blob
2453+
/// </summary>
23712454
String = 7,
2455+
/// <summary>
2456+
/// Single precission complex numbers (32-bit floats)
2457+
/// </summary>
23722458
Complex64 = 8,
2459+
/// <summary>
2460+
/// 32-bit float based complex numbers
2461+
/// </summary>
23732462
Complex = 8,
2463+
/// <summary>
2464+
/// 64-bit signed integers (C# long)
2465+
/// </summary>
23742466
Int64 = 9,
23752467
Bool = 10,
2468+
/// <summary>
2469+
/// Quantized 8-bit signed integer
2470+
/// </summary>
23762471
QInt8 = 11,
2472+
/// <summary>
2473+
/// Quantized 8-bit unsigned integer
2474+
/// </summary>
23772475
QUInt8 = 12,
2476+
/// <summary>
2477+
/// Quantized 32-bit signed integer
2478+
/// </summary>
23782479
QInt32 = 13,
2480+
/// <summary>
2481+
/// Float32 truncated to 16 bits. Only for cast operations.
2482+
/// </summary>
23792483
BFloat16 = 14,
2484+
/// <summary>
2485+
/// Quantized 16-bit signed integer
2486+
/// </summary>
23802487
QInt16 = 15,
2488+
/// <summary>
2489+
/// Quantized 16-bit unsigned integer
2490+
/// </summary>
23812491
QUInt16 = 16,
2492+
/// <summary>
2493+
/// 16-bit unsigned integers (C# long)
2494+
/// </summary>
23822495
UInt16 = 17,
2496+
/// <summary>
2497+
/// Double precission complex numbers (32-bit floats)
2498+
/// </summary>
23832499
Complex128 = 18,
23842500
Half = 19,
23852501
Resource = 20

0 commit comments

Comments
 (0)