Skip to content

Commit b93c4e9

Browse files
authored
Add double initializer to the OptionalColumnTransform onnx export. (dotnet#4751)
1 parent 62dcf5a commit b93c4e9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Microsoft.ML.Transforms/OptionalColumnTransform.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,13 @@ private bool SaveAsOnnxCore(OnnxContext ctx, int iinfo, string srcVariableName,
535535
size = 1;
536536

537537
// REVIEW:
538-
// AddInitializer only supports long, float and string.
539-
// Here we are casting double to float and ulong to long.
540-
// Fixing this would involve adding additional functions to OnnxContext.
541-
if ((type == typeof(float)) || (type == typeof(double)))
538+
// AddInitializer only supports long, float, double and string.
539+
// Here we are casting ulong to long. Fixing this would involve
540+
// adding additional functions to OnnxContext.
541+
if (type == typeof(float))
542542
ctx.AddInitializer(new float[size], new long[] { 1, size }, inputColumnName, false);
543+
else if (type == typeof(double))
544+
ctx.AddInitializer(new double[size], new long[] { 1, size }, inputColumnName, false);
543545
else if ((type == typeof(long)) || (type == typeof(int)) || (type == typeof(short)) || (type == typeof(sbyte)) ||
544546
(type == typeof(ulong)) || (type == typeof(uint)) || (type == typeof(ushort)) || (type == typeof(byte)))
545547
ctx.AddInitializer(new long[size], new long[] { 1, size }, inputColumnName, false);

0 commit comments

Comments
 (0)