Skip to content
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

Fixed onnx export for key types other than uint #5160

Merged
merged 3 commits into from May 26, 2020
Merged

Fixed onnx export for key types other than uint #5160

merged 3 commits into from May 26, 2020

Conversation

harishsk
Copy link
Contributor

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.

@harishsk harishsk requested a review from a team as a code owner May 24, 2020 20:51
@@ -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)
Copy link

@yaeldekel yaeldekel May 26, 2020

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

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)

@yaeldekel
Copy link

yaeldekel commented May 26, 2020

                if (type.GetItemType() != inputNodeInfo.DataViewType.GetItemType())

Please assign type.GetItemType() and inputNodeInfo.DataViewType.GetItemType() to variables to make this more readable. #Resolved


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))
Copy link

@yaeldekel yaeldekel May 26, 2020

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
Copy link

codecov bot commented May 26, 2020

Codecov Report

Merging #5160 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           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           
Flag Coverage Δ
#Debug 75.79% <100.00%> (+<0.01%) ⬆️
#production 71.71% <100.00%> (+<0.01%) ⬆️
#test 88.89% <ø> (ø)
Impacted Files Coverage Δ
test/Microsoft.ML.Tests/OnnxConversionTest.cs 99.38% <ø> (ø)
src/Microsoft.ML.Data/Transforms/Hashing.cs 81.91% <100.00%> (ø)
src/Microsoft.ML.OnnxTransformer/OnnxTransform.cs 92.92% <100.00%> (+0.05%) ⬆️
....ML.AutoML/PipelineSuggesters/PipelineSuggester.cs 83.19% <0.00%> (-3.37%) ⬇️
src/Microsoft.ML.AutoML/Sweepers/Parameters.cs 84.32% <0.00%> (-0.85%) ⬇️
src/Microsoft.ML.TimeSeries/ExtensionsCatalog.cs 95.00% <0.00%> (ø)
...soft.ML.Data/DataLoadSave/Text/TextLoaderCursor.cs 89.58% <0.00%> (+0.32%) ⬆️
...soft.ML.Transforms/Text/WordEmbeddingsExtractor.cs 87.52% <0.00%> (+1.13%) ⬆️
src/Microsoft.ML.Sweeper/AsyncSweeper.cs 73.97% <0.00%> (+1.36%) ⬆️

Copy link

@yaeldekel yaeldekel left a comment

Choose a reason for hiding this comment

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

:shipit:

@harishsk harishsk merged commit b371384 into dotnet:master May 26, 2020
@dotnet dotnet locked as resolved and limited conversation to collaborators Mar 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants