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 output schema of OnnxTransformer #4849

Merged
merged 4 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Microsoft.ML.OnnxConverter/SaveOnnxCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ internal static ModelProto ConvertTransformListToOnnxModel(OnnxContextImpl ctx,
ch.Check(variableName != null, "The targeted pipeline can not be fully converted into a well-defined ONNX model. " +
"Please check if all steps in that pipeline are convertible to ONNX " +
"and all necessary variables are not dropped (via command line arguments).");
var trueVariableName = ctx.AddIntermediateVariable(null, idataviewColumnName + ".onnx", true);
var trueVariableName = ctx.AddIntermediateVariable(null, idataviewColumnName + ".output", true);
ctx.CreateNode("Identity", variableName, trueVariableName, ctx.GetNodeName("Identity"), "");
ctx.AddOutputVariable(outputData.Schema[i].Type, trueVariableName);
}
Expand Down
7 changes: 6 additions & 1 deletion src/Microsoft.ML.OnnxTransformer/OnnxTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,14 @@ public Mapper(OnnxTransformer parent, DataViewSchema inputSchema) :

protected override DataViewSchema.DetachedColumn[] GetOutputColumnsCore()
{
var stdSuffix = ".output";
var info = new DataViewSchema.DetachedColumn[_parent.Outputs.Length];
for (int i = 0; i < _parent.Outputs.Length; i++)
info[i] = new DataViewSchema.DetachedColumn(_parent.Outputs[i], _parent.OutputTypes[i], null);
{
var onnxOutputName = _parent.Outputs[i];
var columnName = onnxOutputName.EndsWith(stdSuffix) ? onnxOutputName.Replace(stdSuffix, "") : onnxOutputName;
info[i] = new DataViewSchema.DetachedColumn(columnName, _parent.OutputTypes[i], null);
}
return info;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
"PredictedLabel"
],
"output": [
"PredictedLabel.onnx"
"PredictedLabel.output"
],
"name": "Identity",
"opType": "Identity"
Expand All @@ -460,7 +460,7 @@
"Score"
],
"output": [
"Score.onnx"
"Score.output"
],
"name": "Identity0",
"opType": "Identity"
Expand All @@ -470,7 +470,7 @@
"Probability"
],
"output": [
"Probability.onnx"
"Probability.output"
],
"name": "Identity1",
"opType": "Identity"
Expand Down Expand Up @@ -533,7 +533,7 @@
],
"output": [
{
"name": "PredictedLabel.onnx",
"name": "PredictedLabel.output",
"type": {
"tensorType": {
"elemType": 9,
Expand All @@ -551,7 +551,7 @@
}
},
{
"name": "Score.onnx",
"name": "Score.output",
"type": {
"tensorType": {
"elemType": 1,
Expand All @@ -569,7 +569,7 @@
}
},
{
"name": "Probability.onnx",
"name": "Probability.output",
"type": {
"tensorType": {
"elemType": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@
"FeatureVector0"
],
"output": [
"FeatureVector.onnx"
"FeatureVector.output"
],
"name": "Identity",
"opType": "Identity"
Expand All @@ -370,7 +370,7 @@
"Target"
],
"output": [
"Target.onnx"
"Target.output"
],
"name": "Identity0",
"opType": "Identity"
Expand All @@ -380,7 +380,7 @@
"Score"
],
"output": [
"Score.onnx"
"Score.output"
],
"name": "Identity1",
"opType": "Identity"
Expand Down Expand Up @@ -427,7 +427,7 @@
],
"output": [
{
"name": "FeatureVector.onnx",
"name": "FeatureVector.output",
"type": {
"tensorType": {
"elemType": 1,
Expand All @@ -445,7 +445,7 @@
}
},
{
"name": "Target.onnx",
"name": "Target.output",
"type": {
"tensorType": {
"elemType": 1,
Expand All @@ -463,7 +463,7 @@
}
},
{
"name": "Score.onnx",
"name": "Score.output",
"type": {
"tensorType": {
"elemType": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"FeatureVector0"
],
"output": [
"FeatureVector.onnx"
"FeatureVector.output"
],
"name": "Identity",
"opType": "Identity"
Expand All @@ -114,7 +114,7 @@
"Target"
],
"output": [
"Target.onnx"
"Target.output"
],
"name": "Identity0",
"opType": "Identity"
Expand All @@ -124,7 +124,7 @@
"Score"
],
"output": [
"Score.onnx"
"Score.output"
],
"name": "Identity1",
"opType": "Identity"
Expand Down Expand Up @@ -171,7 +171,7 @@
],
"output": [
{
"name": "FeatureVector.onnx",
"name": "FeatureVector.output",
"type": {
"tensorType": {
"elemType": 1,
Expand All @@ -189,7 +189,7 @@
}
},
{
"name": "Target.onnx",
"name": "Target.output",
"type": {
"tensorType": {
"elemType": 1,
Expand All @@ -207,7 +207,7 @@
}
},
{
"name": "Score.onnx",
"name": "Score.output",
"type": {
"tensorType": {
"elemType": 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,27 +677,27 @@
"floats": [
-0.9850374,
-1,
-0.428571433,
-0.42857143,
0.05882353,
0.9655172,
0.478260875,
7.006492E-45,
0.47826087,
7E-45,
0.9354839,
-0.837172,
-0.896625638,
-0.89662564,
-0.3455931,
0.223126009,
0.22312601,
0.8040303,
0.60825175,
-0.06932944,
-0.402043074,
-0.40204307,
-0.7417274,
-0.408434927,
-0.40843493,
0.7105746,
0.1875386,
0.7631735,
0.706173241,
0.625906467,
0.70617324,
0.62590647,
-0.35968104
],
"type": "FLOATS"
Expand Down Expand Up @@ -776,7 +776,7 @@
"PredictedLabel"
],
"output": [
"PredictedLabel.onnx"
"PredictedLabel.output"
],
"name": "Identity",
"opType": "Identity"
Expand All @@ -786,7 +786,7 @@
"Score"
],
"output": [
"Score.onnx"
"Score.output"
],
"name": "Identity0",
"opType": "Identity"
Expand All @@ -796,7 +796,7 @@
"Probability"
],
"output": [
"Probability.onnx"
"Probability.output"
],
"name": "Identity1",
"opType": "Identity"
Expand Down Expand Up @@ -859,7 +859,7 @@
],
"output": [
{
"name": "PredictedLabel.onnx",
"name": "PredictedLabel.output",
"type": {
"tensorType": {
"elemType": 9,
Expand All @@ -877,7 +877,7 @@
}
},
{
"name": "Score.onnx",
"name": "Score.output",
"type": {
"tensorType": {
"elemType": 1,
Expand All @@ -895,7 +895,7 @@
}
},
{
"name": "Probability.onnx",
"name": "Probability.output",
"type": {
"tensorType": {
"elemType": 1,
Expand Down
Loading