Browse Source

Tensor: Added explicit cast to string

tags/v0.12
Eli Belash 6 years ago
parent
commit
4cf817ea18
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      src/TensorFlowNET.Core/Tensors/Tensor.Explicit.cs

+ 10
- 0
src/TensorFlowNET.Core/Tensors/Tensor.Explicit.cs View File

@@ -115,6 +115,16 @@ namespace Tensorflow
}
}

public static explicit operator string(Tensor tensor)
{
unsafe
{
EnsureScalar(tensor);
EnsureDType(tensor, TF_DataType.TF_STRING);
return new string((char*) tensor.buffer, 0, (int) tensor.size);
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void EnsureDType(Tensor tensor, TF_DataType @is)
{


Loading…
Cancel
Save