Browse Source

Merge branch 'master' into rnn-dev

tags/v0.110.0-LSTM-Model
Rinne GitHub 2 years ago
parent
commit
649db149e1
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 1 deletions
  1. +19
    -1
      src/TensorFlowNET.Core/APIs/c_api.cs

+ 19
- 1
src/TensorFlowNET.Core/APIs/c_api.cs View File

@@ -55,10 +55,28 @@ namespace Tensorflow
{
if(handle is null){
return new byte[0];
}
var data = handle.ToArray();
return data;
}
public unsafe static byte[] ByteStringPieceFromNativeString(IntPtr handle)
{
if (handle == IntPtr.Zero)
{
return new byte[0];
}

byte* str_data = (byte*)handle.ToPointer();
List<byte> bytes = new List<byte>();
byte current = 255;
while (current != ((byte)'\0'))
{
current = *(str_data++);
bytes.Add(current);
}
var data = bytes.ToArray();
return data;
}

[UnmanagedFunctionPointer(CallingConvention.Winapi)]
public delegate void Deallocator(IntPtr data, IntPtr size, ref DeallocatorArgs args);


Loading…
Cancel
Save