Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/Microsoft.ML.Data/Transforms/Hashing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ private bool SaveAsOnnxCore(OnnxContext ctx, int iinfo, string srcVariable, stri
// Since these numeric types are not supported by Onnxruntime, we cast them to UInt32.
if (srcType == NumberDataViewType.UInt16 || srcType == NumberDataViewType.Int16 ||
srcType == NumberDataViewType.SByte || srcType == NumberDataViewType.Byte ||
srcType == BooleanDataViewType.Instance)
srcType == BooleanDataViewType.Instance || srcType is KeyDataViewType)

@yaeldekel yaeldekel May 26, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

srcType is KeyDataViewType [](start = 63, length = 26)

For the key type case, you also need to check that RawType is either byte or ushort, because for uint and ulong you don't need to add the cast node. #Resolved

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I was looking at the previous iteration.


In reply to: 430171432 [](ancestors = 430171432)

{
castOutput = ctx.AddIntermediateVariable(NumberDataViewType.UInt32, "CastOutput", true);
castNode = ctx.CreateNode("Cast", srcVariable, castOutput, ctx.GetNodeName(opType), "");
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.ML.OnnxTransformer/OnnxTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public Mapper(OnnxTransformer parent, DataViewSchema inputSchema) :
// then throw an exception.
// This is done except in the case where the ONNX model input node expects a UInt32 but the input column is actually KeyDataViewType
// This is done to support a corner case originated in NimbusML. For more info, see: https://github.com/microsoft/NimbusML/issues/426
if (!(type.GetItemType() is KeyDataViewType && inputNodeInfo.DataViewType.GetItemType().RawType == typeof(UInt32)))
if (!(type.GetItemType() is KeyDataViewType && type.GetItemType().RawType == inputNodeInfo.DataViewType.GetItemType().RawType))

@yaeldekel yaeldekel May 26, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if [](start = 24, length = 2)

Nit: can you convert this condition to !A || !B instead of !(A && B)? I find it easier to read :). #Resolved

throw Host.ExceptSchemaMismatch(nameof(inputSchema), "input", _parent.Inputs[i], inputNodeInfo.DataViewType.GetItemType().ToString(), type.ToString());
}

Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.ML.Tests/OnnxConversionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ private class HashData
[Theory]
[CombinatorialData]
public void MurmurHashKeyTest(
[CombinatorialValues(/*DataKind.Byte, DataKind.UInt16, */DataKind.UInt32/*, DataKind.UInt64*/)]DataKind keyType)
[CombinatorialValues(DataKind.Byte, DataKind.UInt16, DataKind.UInt32, DataKind.UInt64)]DataKind keyType)
{
var dataFile = DeleteOutputPath("KeysToOnnx.txt");
File.WriteAllLines(dataFile,
Expand Down