-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New ONNX converter interface and some tests #2013
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ebd8a60
Prototype of new ONNX converter and an end-to-end test
wschin a3a2fe2
Reuse existing code to do conversion and polish a test
wschin f6d5574
Test Kmeans as well
wschin ee4d201
1. Introduce ONNX conversion as an extention to MLContext
wschin 4f187b1
Add test comparison
wschin 0618319
Address comments
wschin e950b28
Propose another domain name
wschin dc2be31
Add missing header
wschin 987dc82
One more test for one-hot encoding's conversion
wschin e6d42a1
Add one more test
wschin 13c58db
Add logistic regression test
wschin 26a0649
Add LightGBM test
wschin 984e9d2
Test NaN replacement and fix build for core30 and x86
wschin 66e6367
Add one more test
wschin 1a36b37
Update Kmeans file due to change of initialization
wschin 7d517ec
Add a test for onnx conversion cmd
wschin d93f8a5
Add word embedding test
wschin b683a5a
Remove old tests
wschin 0949f80
increase tol
wschin 1323bd9
Drop version in saved baseline file
wschin 8bb700f
make c30 happy
wschin d0c4cb9
Make c30 happier
wschin 30bf2d6
c30 needs even more
wschin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
| // See the LICENSE file in the project root for more information. | ||
|
|
||
| using System.Collections.Generic; | ||
| using Microsoft.ML.Core.Data; | ||
| using Microsoft.ML.Data; | ||
| using Microsoft.ML.Model.Onnx; | ||
| using Microsoft.ML.UniversalModelFormat.Onnx; | ||
|
|
||
| namespace Microsoft.ML | ||
| { | ||
| public static class OnnxExportExtensions | ||
| { | ||
| /// <summary> | ||
| /// Convert the specified <see cref="ITransformer"/> to ONNX format. Note that ONNX uses Google's Protobuf so the returned value is a Protobuf object. | ||
| /// </summary> | ||
| /// <param name="catalog">The class that <see cref="ConvertToOnnx(ModelOperationsCatalog, ITransformer, IDataView)"/> attached to.</param> | ||
| /// <param name="transform">The <see cref="ITransformer"/> that will be converted into ONNX format.</param> | ||
| /// <param name="inputData">The input of the specified transform.</param> | ||
| /// <returns>An ONNX model equivalent to the converted ML.NET model.</returns> | ||
| public static ModelProto ConvertToOnnx(this ModelOperationsCatalog catalog, ITransformer transform, IDataView inputData) | ||
| { | ||
| var env = catalog.Environment; | ||
| var ctx = new OnnxContextImpl(env, "model", "ML.NET", "0", 0, "machinelearning.dotnet", OnnxVersion.Stable); | ||
| var outputData = transform.Transform(inputData); | ||
| LinkedList<ITransformCanSaveOnnx> transforms = null; | ||
| using (var ch = env.Start("ONNX conversion")) | ||
| { | ||
| SaveOnnxCommand.GetPipe(ctx, ch, outputData, out IDataView root, out IDataView sink, out transforms); | ||
| return SaveOnnxCommand.ConvertTransformListToOnnxModel(ctx, ch, root, sink, transforms, null, null); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.