Skip to content
Draft
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
6 changes: 6 additions & 0 deletions Samples/WindowsML/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Windows ML enables high-performance, reliable inferencing of machine learning mo
|--------|-------------|--------------|
| [cpp-abi](cpp-abi/) | Direct ABI implementation using raw COM interfaces | Automatic ABI header generation, no projections |

### CMake Samples

| Sample | Description | Key Features |
|--------|-------------|--------------|
| [cmake/WinMLEpCatalog](cmake/WinMLEpCatalog/) | WinMLEpCatalog Native C API with CMake/vcpkg | Native C API, no WinRT dependencies, interactive shell |

### C# Samples

#### Console Applications
Expand Down
49 changes: 49 additions & 0 deletions Samples/WindowsML/cmake/WinMLEpCatalog/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
# Clang-format configuration for WinML EP Catalog Sample

BasedOnStyle: Microsoft
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 120

# Braces
BreakBeforeBraces: Allman
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false

# Indentation
NamespaceIndentation: None
IndentCaseLabels: false

# Alignment
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignOperands: true
AlignTrailingComments: true

# Line breaks
AllowAllParametersOfDeclarationOnNextLine: true
BinPackArguments: false
BinPackParameters: false

# Includes
SortIncludes: true
IncludeBlocks: Preserve

# Pointer alignment
PointerAlignment: Left

# Spaces
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
25 changes: 25 additions & 0 deletions Samples/WindowsML/cmake/WinMLEpCatalog/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Build outputs
out/
build/

# CMake cache
CMakeCache.txt
CMakeFiles/

# vcpkg downloads
vcpkg_installed/

# Local package overrides (for development/testing)
local_packages/

# IDE files
.vs/
.vscode/
*.user

# Compiled files
*.exe
*.dll
*.pdb
*.obj
*.ilk
55 changes: 55 additions & 0 deletions Samples/WindowsML/cmake/WinMLEpCatalog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (C) Microsoft Corporation. All rights reserved.
cmake_minimum_required(VERSION 3.21)

project(WinMLEpCatalogSample
VERSION 1.0.0
DESCRIPTION "Windows ML Execution Provider Catalog Sample with ONNX Runtime Integration"
LANGUAGES CXX
)

# Find the Windows ML package installed via vcpkg
find_package(microsoft-windows-ai-machinelearning CONFIG REQUIRED)

# C++20 standard for modern features (std::format, etc.)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Create the executable
add_executable(WinMLEpCatalogSample
main.cpp
)

# Link against the Windows ML API and ONNX Runtime
# WindowsML::Api provides the WinMLEpCatalog* functions
# WindowsML::OnnxRuntime provides access to the ONNX Runtime C/C++ API for creating OrtEnv and registering providers
target_link_libraries(WinMLEpCatalogSample
PRIVATE
WindowsML::Api
WindowsML::OnnxRuntime
)

# Copy runtime DLLs to the build output directory
# This is required because the Windows ML DLLs must be present alongside the executable
winml_copy_runtime_dlls(WinMLEpCatalogSample)

# Set Windows-specific compiler options
if(MSVC)
target_compile_options(WinMLEpCatalogSample PRIVATE
/W4 # Warning level 4
/permissive- # Strict C++ conformance
/Zc:__cplusplus # Report correct __cplusplus value
/EHsc # Enable C++ exception handling
)

# Use static runtime for easier deployment (no MSVC runtime dependency)
set_property(TARGET WinMLEpCatalogSample PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)
endif()

# Set subsystem to console (not Windows GUI)
if(WIN32)
set_target_properties(WinMLEpCatalogSample PROPERTIES
WIN32_EXECUTABLE FALSE
)
endif()
167 changes: 167 additions & 0 deletions Samples/WindowsML/cmake/WinMLEpCatalog/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{
"version": 3,
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "base-vs",
"hidden": true,
"generator": "Visual Studio 17 2022",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "x64-debug",
"displayName": "x64 Debug",
"description": "Build for x64 architecture in Debug mode",
"inherits": "base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "x64-release",
"displayName": "x64 Release",
"description": "Build for x64 architecture in Release mode",
"inherits": "base",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "arm64-debug",
"displayName": "ARM64 Debug",
"description": "Build for ARM64 architecture in Debug mode",
"inherits": "base",
"architecture": {
"value": "arm64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"VCPKG_TARGET_TRIPLET": "arm64-windows"
}
},
{
"name": "arm64-release",
"displayName": "ARM64 Release",
"description": "Build for ARM64 architecture in Release mode",
"inherits": "base",
"architecture": {
"value": "arm64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"VCPKG_TARGET_TRIPLET": "arm64-windows"
}
},
{
"name": "x64-debug-vs",
"displayName": "x64 Debug (VS)",
"description": "Build for x64 architecture in Debug mode (Visual Studio generator)",
"inherits": "base-vs",
"architecture": {
"value": "x64",
"strategy": "set"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "x64-release-vs",
"displayName": "x64 Release (VS)",
"description": "Build for x64 architecture in Release mode (Visual Studio generator)",
"inherits": "base-vs",
"architecture": {
"value": "x64",
"strategy": "set"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
},
{
"name": "arm64-debug-vs",
"displayName": "ARM64 Debug (VS)",
"description": "Build for ARM64 architecture in Debug mode (Visual Studio generator)",
"inherits": "base-vs",
"architecture": {
"value": "ARM64",
"strategy": "set"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "arm64-windows"
}
},
{
"name": "arm64-release-vs",
"displayName": "ARM64 Release (VS)",
"description": "Build for ARM64 architecture in Release mode (Visual Studio generator)",
"inherits": "base-vs",
"architecture": {
"value": "ARM64",
"strategy": "set"
},
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "arm64-windows"
}
}
],
"buildPresets": [
{
"name": "x64-debug",
"configurePreset": "x64-debug"
},
{
"name": "x64-release",
"configurePreset": "x64-release"
},
{
"name": "arm64-debug",
"configurePreset": "arm64-debug"
},
{
"name": "arm64-release",
"configurePreset": "arm64-release"
},
{
"name": "x64-debug-vs",
"configurePreset": "x64-debug-vs",
"configuration": "Debug"
},
{
"name": "x64-release-vs",
"configurePreset": "x64-release-vs",
"configuration": "Release"
},
{
"name": "arm64-debug-vs",
"configurePreset": "arm64-debug-vs",
"configuration": "Debug"
},
{
"name": "arm64-release-vs",
"configurePreset": "arm64-release-vs",
"configuration": "Release"
}
]
}
Loading