Integrate a model into your app with Windows ML

In this guide, we'll cover how to use the Windows ML APIs to integrate a model into your Windows app. Alternatively, if you'd like to use Windows ML's automatic code generator, check out mlgen.

Important APIs: Windows.AI.MachineLearning

We'll go over the basic building blocks of Windows ML, which are:

  • Models
  • Sessions
  • Devices
  • Bindings

You'll use these to load, bind, and evaluate your models with Windows ML.

We also recommend taking a look at our sample apps on GitHub to see end-to-end Windows ML code examples.

The following video shows these APIs in action in a short demo.

Using WinML APIs in C++

While the WinML APIs are available in both C++/CX and C++/WinRT, we recommend using the C++/WinRT version, as it allows for more natural C++ coding and is where most development efforts will be focused going forward. You can follow the instructions below that pertain to your particular situation to use the C++/WinRT APIs:

  • If you are targeting Windows 1803 or earlier, see Tutorial: Port an Existing WinML App to NuGet Package.
  • If you are creating a new C++ application, see Tutorial: Create a Windows Machine Learning Desktop application (C++) and follow the steps up to Load the model.
  • If you have an existing C++ application (which is not already set up for C++/WinRT), follow these steps to set up your application for C++/WinRT:
    1. Make sure you have the latest version of Visual Studio 2019 installed (any edition).
    2. Make sure you have the SDK for Windows 10, version 1803 or later.
    3. Download and install the C++/WinRT Visual Studio Extension (VSIX) from the Visual Studio Marketplace.
    4. Add the <CppWinRTEnabled>true</CppWinRTEnabled> property to the project's .vcxproj file:
      <Project ...>
          <PropertyGroup Label="Globals">
    5. C++/WinRT requires features from the C++17 standard, so in your project properties, set C/C++ > Language > C++ Language Standard > ISO C++17 Standard (/std:c++17).
    6. Set Conformance mode: Yes (/permissive-) in your project properties.
    7. Another project property to be aware of is C/C++ > General > Treat Warnings As Errors. Set this to Yes (/WX) or No (/WX-) to taste. Sometimes, source files generated by the cppwinrt.exe tool generate warnings until you add your implementation to them.
    8. The VSIX also gives you Visual Studio native debug visualization (natvis) of C++/WinRT projected types, providing an experience similar to C# debugging. Natvis is automatic for debug builds. You can opt into its release builds by defining the symbol WINRT_NATVIS.
    9. Your project should now be setup for C++/WinRT. See C++/WinRT for more information.


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.
  • To request a feature, please head over to Windows Developer Feedback.