Skip to content

Commit 2983c21

Browse files
committed
Handful of 1.5.0 APIs that had to be manually bound
1 parent 8cdbf83 commit 2983c21

File tree

1 file changed

+72
-1
lines changed

1 file changed

+72
-1
lines changed

TensorFlowSharp/Tensorflow.cs

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,29 @@ public TFFunction ToFunction (string functionName,
11671167
return new TFFunction (fnHandle);
11681168
}
11691169
}
1170-
1170+
1171+
[DllImport (NativeBinding.TensorFlowLibrary)]
1172+
unsafe extern static void TF_GraphVersions (TF_Graph graph, LLBuffer *output_version_def, TF_Status status);
1173+
1174+
/// <summary>
1175+
/// Returns the serialized VersionDef proto for this graph.
1176+
/// </summary>
1177+
/// <returns>The versions.</returns>
1178+
/// <param name="outputVersionDef">The buffer where the serialized protocol buffer will be stored.</param>
1179+
/// <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>
1180+
public void Versions (TFBuffer outputVersionDef, TFStatus status = null)
1181+
{
1182+
if (handle == IntPtr.Zero)
1183+
ObjectDisposedException ();
1184+
if (outputVersionDef == null)
1185+
throw new ArgumentNullException (nameof (outputVersionDef));
1186+
1187+
var cstatus = TFStatus.Setup (status);
1188+
unsafe {
1189+
TF_GraphVersions (handle, outputVersionDef.LLBuffer, cstatus.handle);
1190+
}
1191+
cstatus.CheckMaybeRaise (status);
1192+
}
11711193
}
11721194

11731195
//
@@ -2165,6 +2187,8 @@ public int NumReturnOutputs {
21652187
/// </remarks>
21662188
public void RemapControlDependency (string srcName, TFOperation destination)
21672189
{
2190+
if (handle == IntPtr.Zero)
2191+
ObjectDisposedException ();
21682192
if (srcName == null)
21692193
throw new ArgumentNullException (nameof (srcName));
21702194
if (destination == null)
@@ -2173,6 +2197,45 @@ public void RemapControlDependency (string srcName, TFOperation destination)
21732197
throw new ObjectDisposedException (nameof (destination));
21742198
TF_ImportGraphDefOptionsRemapControlDependency (handle, srcName, destination.Handle);
21752199
}
2200+
2201+
[DllImport (NativeBinding.TensorFlowLibrary)]
2202+
extern static void TF_ImportGraphDefOptionsSetUniquifyNames (TF_ImportGraphDefOptions opts, byte uniquify);
2203+
2204+
/// <summary>
2205+
/// Set whether to uniquify imported operation names.
2206+
/// </summary>
2207+
/// <param name="uniquifyNames">If set to <c>true</c> imported operation names will be modified if their name already exists in the graph.
2208+
/// If set to <c>false</c> conflicting names will be treated as an error.
2209+
/// </param>
2210+
/// <remarks>
2211+
/// Note that this option has no effect if a prefix is set, since the prefix will guarantee all names are
2212+
/// Defaults to false.
2213+
/// </remarks>
2214+
public void SetUniquifyNames (bool uniquifyNames)
2215+
{
2216+
if (handle == IntPtr.Zero)
2217+
ObjectDisposedException ();
2218+
2219+
TF_ImportGraphDefOptionsSetUniquifyNames (handle, uniquifyNames ? (byte) 1 : (byte) 0);
2220+
}
2221+
2222+
[DllImport (NativeBinding.TensorFlowLibrary)]
2223+
extern static void TF_ImportGraphDefOptionsSetUniquifyPrefix (TF_ImportGraphDefOptions opts, byte uniquify_prefix);
2224+
2225+
/// <summary>
2226+
/// Sets the uniquify prefix. This option has no effect if no prefix is specified.
2227+
/// </summary>
2228+
/// <param name="uniquifyPrefix">If set to <c>true</c> the specified prefix will be modified if it already exists as an
2229+
/// operation name or prefix in the graph.
2230+
/// If set to <c>false</c> a conflicting prefix will be treated as an error.
2231+
/// </param>
2232+
public void SetUniquifyPrefix (bool uniquifyPrefix)
2233+
{
2234+
if (handle == IntPtr.Zero)
2235+
ObjectDisposedException ();
2236+
TF_ImportGraphDefOptionsSetUniquifyPrefix (handle, uniquifyPrefix ? (byte)1 : (byte)0);
2237+
}
2238+
21762239
}
21772240

21782241
/// <summary>
@@ -2892,7 +2955,15 @@ public enum TFDataType : uint
28922955
/// </summary>
28932956
Variant = 21,
28942957

2958+
/// <summary>
2959+
/// 32-bit unsigned integers
2960+
/// </summary>
2961+
UInt32 = 22,
28952962

2963+
/// <summary>
2964+
/// 64-bit unsigned integers
2965+
/// </summary>
2966+
UInt64 = 23
28962967
}
28972968

28982969
/// <summary>

0 commit comments

Comments
 (0)