-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixed onnx export for key types other than uint #5160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please assign Refers to: src/Microsoft.ML.OnnxTransformer/OnnxTransform.cs:392 in 4bf1a5d. [](commit_id = 4bf1a5d, deletion_comment = False) |
@@ -395,7 +395,7 @@ private sealed class Mapper : MapperBase | |||
// 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)) |
There was a problem hiding this comment.
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
Codecov Report
@@ Coverage Diff @@
## master #5160 +/- ##
=======================================
Coverage 75.79% 75.79%
=======================================
Files 993 993
Lines 180969 180972 +3
Branches 19489 19489
=======================================
+ Hits 137159 137165 +6
+ Misses 38516 38513 -3
Partials 5294 5294
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In PR #5152 @yaeldekel modified the test for onnx export for key types and disabled the test for types other than uint because of a bug in onnx export for those other types. This PR takes the test from @yaeldekel's PR and adds the fix for the onnx export bug.