Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Microsoft.ML.TensorFlow/TensorflowUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Text;
using Microsoft.ML.Data;
using Microsoft.ML.Internal.Utilities;
using Microsoft.ML.Runtime;
Expand Down Expand Up @@ -440,13 +441,13 @@ internal static Tensor CastDataAndReturnAsTensor<T>(T[] data, TensorShape tfShap
return new Tensor((double[])(object)data, dims, TF_DataType.TF_DOUBLE);
else if (typeof(T) == typeof(ReadOnlyMemory<char>))
{
string[] strings = new string[data.Length];
for (int i = 0; i < strings.Length; i++)
byte[][] bytes = new byte[data.Length][];
for (int i = 0; i < bytes.Length; i++)
{
strings[i] = data[i].ToString();
bytes[i] = Encoding.Unicode.GetBytes(((ReadOnlyMemory<char>)(object)data[i]).ToArray());
}

return new Tensor(strings);
return new Tensor(bytes, TF_DataType.TF_STRING);
}

return new Tensor(new NDArray(data, tfShape));
Expand Down