Skip to content

Commit 30314fd

Browse files
committed
Some doc work
1 parent e331d19 commit 30314fd

File tree

1 file changed

+72
-4
lines changed

1 file changed

+72
-4
lines changed

TensorFlowSharp/Tensorflow.cs

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,12 @@ public class TFSession : TFDisposable
19511951
Graph = graph;
19521952
}
19531953

1954+
/// <summary>
1955+
/// Creates a new execution session associated with the specified session graph with some configuration options.
1956+
/// </summary>
1957+
/// <param name="graph">The Graph to which this session is associated.</param>
1958+
/// <param name="sessionOptions">Session options.</param>
1959+
/// <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>
19541960
public TFSession (TFGraph graph, TFSessionOptions sessionOptions, TFStatus status = null) : base (IntPtr.Zero)
19551961
{
19561962
Graph = graph;
@@ -1960,6 +1966,11 @@ public TFSession (TFGraph graph, TFSessionOptions sessionOptions, TFStatus statu
19601966
handle = h;
19611967
}
19621968

1969+
/// <summary>
1970+
/// Creates a new execution session associated with the specified session graph.
1971+
/// </summary>
1972+
/// <param name="graph">The Graph to which this session is associated.</param>
1973+
/// <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>
19631974
public TFSession (TFGraph graph, TFStatus status = null) : base (IntPtr.Zero)
19641975
{
19651976
Graph = graph;
@@ -1971,6 +1982,13 @@ public TFSession (TFGraph graph, TFStatus status = null) : base (IntPtr.Zero)
19711982
handle = h;
19721983
}
19731984

1985+
/// <summary>
1986+
/// Creates a new execution session with an empty graph
1987+
/// </summary>
1988+
/// <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>
1989+
/// <remarks>
1990+
/// The created graph can be retrieved using the Graph property on the session.
1991+
/// </remarks>
19741992
public TFSession (TFStatus status = null) : this (new TFGraph (), status)
19751993
{
19761994
}
@@ -1979,6 +1997,21 @@ public TFSession (TFStatus status = null) : this (new TFGraph (), status)
19791997
[DllImport (NativeBinding.TensorFlowLibrary)]
19801998
static extern unsafe TF_Session TF_LoadSessionFromSavedModel (TF_SessionOptions session_options, LLBuffer* run_options, string export_dir, string [] tags, int tags_len, TF_Graph graph, LLBuffer* meta_graph_def, TF_Status status);
19811999

2000+
/// <summary>
2001+
/// Creates a session and graph from a saved session model
2002+
/// </summary>
2003+
/// <returns>On success, this populates the provided <paramref name="graph"/> with the contents of the graph stored in the specified model and <paramref name="metaGraphDef"/> with the MetaGraphDef of the loaded model.</returns>
2004+
/// <param name="sessionOptions">Session options to use for the new session.</param>
2005+
/// <param name="runOptions">Options to use to initialize the state (can be null).</param>
2006+
/// <param name="exportDir">must be set to the path of the exported SavedModel.</param>
2007+
/// <param name="tags">must include the set of tags used to identify one MetaGraphDef in the SavedModel.</param>
2008+
/// <param name="graph">This must be a newly created graph.</param>
2009+
/// <param name="metaGraphDef">On success, this will be populated on return with the contents of the MetaGraphDef (can be null).</param>
2010+
/// <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>
2011+
/// <remarks>
2012+
/// This function creates a new session using the specified <paramref name="sessionOptions"/> and then initializes
2013+
/// the state (restoring tensors and other assets) using <paramref name="runOptions"/>
2014+
/// </remarks>
19822015
public TFSession FromSavedModel (TFSessionOptions sessionOptions, TFBuffer runOptions, string exportDir, string [] tags, TFGraph graph, TFBuffer metaGraphDef, TFStatus status = null)
19832016
{
19842017
if (graph == null)
@@ -1987,14 +2020,12 @@ public TFSession FromSavedModel (TFSessionOptions sessionOptions, TFBuffer runOp
19872020
throw new ArgumentNullException (nameof (tags));
19882021
if (exportDir == null)
19892022
throw new ArgumentNullException (nameof (exportDir));
1990-
if (runOptions == null)
1991-
throw new ArgumentNullException (nameof (runOptions));
19922023
if (metaGraphDef == null)
19932024
throw new ArgumentNullException (nameof (metaGraphDef));
19942025
var cstatus = TFStatus.Setup (status);
19952026
unsafe
19962027
{
1997-
var h = TF_LoadSessionFromSavedModel (sessionOptions.handle, runOptions.LLBuffer, exportDir, tags, tags.Length, graph.handle, metaGraphDef.LLBuffer, cstatus.handle);
2028+
var h = TF_LoadSessionFromSavedModel (sessionOptions.handle, runOptions == null ? null : runOptions.LLBuffer, exportDir, tags, tags.Length, graph.handle, metaGraphDef == null ? null : metaGraphDef.LLBuffer, cstatus.handle);
19982029

19992030
if (cstatus.CheckMaybeRaise (status)) {
20002031
return new TFSession (h, graph);
@@ -2007,6 +2038,13 @@ public TFSession FromSavedModel (TFSessionOptions sessionOptions, TFBuffer runOp
20072038
[DllImport (NativeBinding.TensorFlowLibrary)]
20082039
static extern unsafe void TF_CloseSession (TF_Session session, TF_Status status);
20092040

2041+
/// <summary>
2042+
/// Closes the session. Contacts any other processes associated with the session, if applicable.
2043+
/// </summary>
2044+
/// <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>
2045+
/// <remarks>
2046+
/// Can not be called after calling DeleteSession.
2047+
/// </remarks>
20102048
public void CloseSession (TFStatus status = null)
20112049
{
20122050
if (handle == IntPtr.Zero)
@@ -2429,13 +2467,31 @@ public TFTensor [] PartialRun (PartialRunToken token, TFOutput [] inputs, TFTens
24292467
}
24302468
}
24312469

2470+
/// <summary>
2471+
/// Represents a dynamically loaded library of TensorFlow operations, use to load and consume TensorFlow operations from an external library.
2472+
/// </summary>
2473+
/// <remarks>
2474+
/// Use the static method <see cref="M:Tensorflow.TFLibrary.FromFile"/> to load a dynamic library.
2475+
/// Once that function returns
2476+
/// </remarks>
24322477
public class TFLibrary : TFDisposable {
24332478
// extern TF_Library * TF_LoadLibrary (const char *library_filename, TF_Status *status);
24342479
[DllImport (NativeBinding.TensorFlowLibrary)]
24352480
static extern unsafe TF_Library TF_LoadLibrary (string library_filename, TF_Status status);
24362481

24372482
TFLibrary (IntPtr handle) : base (handle) { }
24382483

2484+
/// <summary>
2485+
/// Load the library specified by and register the operations and
2486+
/// kernels present in that library.
2487+
/// </summary>
2488+
/// <returns>Handle to the loaded library.</returns>
2489+
/// <param name="libraryFile">Name of the library to load, this is a platform specific name.</param>
2490+
/// <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>
2491+
/// <remarks>
2492+
/// The provided <paramref name="libraryFile"/> is passed to the operating system dynamic loader
2493+
/// and it will load the library using the operating system defined search paths and rules to load this.
2494+
/// </remarks>
24392495
public static TFLibrary FromFile (string libraryFile, TFStatus status = null)
24402496
{
24412497
var cstatus = TFStatus.Setup (status);
@@ -2551,8 +2607,20 @@ public enum TFDataType : uint
25512607
/// Double precission complex numbers (32-bit floats)
25522608
/// </summary>
25532609
Complex128 = 18,
2610+
2611+
/// <summary>
2612+
/// Half floats - 16-bit half precision floating point.
2613+
/// </summary>
25542614
Half = 19,
2555-
Resource = 20
2615+
2616+
/// <summary>
2617+
/// Handle to a mutable resource.
2618+
/// </summary>
2619+
Resource = 20,
2620+
2621+
/// <summary>
2622+
/// Variant data type
2623+
/// </summary>
25562624
}
25572625

25582626
/// <summary>

0 commit comments

Comments
 (0)