Skip to content

Commit 4bc6602

Browse files
committed
c_api: TF_NewTensor now allows pinned managed objects to be passed down to TF (needed different deallocator arg type)
1 parent 9a58ebb commit 4bc6602

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/TensorFlowNET.Core/APIs/c_api.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,13 @@ public static string StringPiece(IntPtr handle)
5353
return handle == IntPtr.Zero ? String.Empty : Marshal.PtrToStringAnsi(handle);
5454
}
5555

56-
public delegate void Deallocator(IntPtr data, IntPtr size, ref bool deallocator);
56+
public delegate void Deallocator(IntPtr data, IntPtr size, ref DeallocatorArgs args);
57+
58+
public struct DeallocatorArgs
59+
{
60+
public bool deallocator_called;
61+
public IntPtr gc_handle;
62+
}
5763

5864
[DllImport(TensorFlowLibName)]
5965
public static unsafe extern IntPtr TF_Version();

src/TensorFlowNET.Core/Tensors/c_api.tensor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public partial class c_api
7171
/// <param name="deallocator_arg"></param>
7272
/// <returns></returns>
7373
[DllImport(TensorFlowLibName)]
74-
public static extern IntPtr TF_NewTensor(TF_DataType dataType, long[] dims, int num_dims, IntPtr data, UIntPtr len, Deallocator deallocator, ref bool deallocator_arg);
74+
public static extern IntPtr TF_NewTensor(TF_DataType dataType, long[] dims, int num_dims, IntPtr data, UIntPtr len, Deallocator deallocator, ref DeallocatorArgs deallocator_arg);
7575

7676
/// <summary>
7777
/// Return the number of dimensions that the tensor has.

0 commit comments

Comments
 (0)