Automatic code generation with mlgen

Windows Machine Learning's code generator mlgen creates an interface (C#, C++/WinRT, and C++/CX) with wrapper classes that call the Windows ML API for you, allowing you to easily load, bind, and evaluate a model in your project.

Getting the tool

mlgen is provided as a Visual Studio extension for developers creating WinML applications in VS 2017 or later.

In Windows 10, version 1903 and later, mlgen is no longer included in the Windows 10 SDK, so you must download and install the extension. There is one for Visual Studio 2017 and one for Visual Studio 2019.

Using mglen

Once you have mlgen installed, inside your Visual Studio project, add your ONNX file to your project’s Assets folder, and VS will generate Windows ML wrapper classes in a new interface file. You can use these classes and methods to integrate your model into your application.

Note

Use the following resources for help with Windows ML:

  • To ask or answer technical questions about Windows ML, please use the windows-machine-learning tag on Stack Overflow.
  • To report a bug, please file an issue on our GitHub.