mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-01 03:45:06 +00:00
Switch to unified DirectML 1.4.0 redistributable (#5794)
Transitions from the ORT-only DML NuGet (hosted on the onnxruntime_public feed) to the new unified DirectML NuGet (Microsoft.AI.DirectML) on nuget.org. In addition, the Microsoft.AI.MachineLearning (WinML) and Microsoft.ML.OnnxRuntime.DirectML packages now take a dependency on the Microsoft.AI.DirectML package. This means we can remove the extra copy of DML binaries in these packages since they will be installed by the DML package.
This commit is contained in:
parent
c84bc25e28
commit
bd236ecc26
14 changed files with 48 additions and 60 deletions
6
cmake/external/dml.cmake
vendored
6
cmake/external/dml.cmake
vendored
|
|
@ -20,18 +20,18 @@ if (NOT onnxruntime_USE_CUSTOM_DIRECTML)
|
|||
set(NUGET_CONFIG ${PROJECT_SOURCE_DIR}/../NuGet.config)
|
||||
set(PACKAGES_CONFIG ${PROJECT_SOURCE_DIR}/../packages.config)
|
||||
get_filename_component(PACKAGES_DIR ${CMAKE_CURRENT_BINARY_DIR}/../packages ABSOLUTE)
|
||||
set(DML_PACKAGE_DIR ${PACKAGES_DIR}/DirectML.1.3.0)
|
||||
set(DML_PACKAGE_DIR ${PACKAGES_DIR}/Microsoft.AI.DirectML.1.4.0)
|
||||
set(DML_SHARED_LIB DirectML.dll)
|
||||
|
||||
# Restore nuget packages, which will pull down the DirectML redist package
|
||||
add_custom_command(
|
||||
OUTPUT ${DML_PACKAGE_DIR}/bin/x64/DirectML.lib ${DML_PACKAGE_DIR}/bin/x86/DirectML.lib
|
||||
OUTPUT ${DML_PACKAGE_DIR}/bin/x64-win/DirectML.lib ${DML_PACKAGE_DIR}/bin/x86-win/DirectML.lib
|
||||
DEPENDS ${PACKAGES_CONFIG} ${NUGET_CONFIG}
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/nuget/src/nuget restore ${PACKAGES_CONFIG} -PackagesDirectory ${PACKAGES_DIR} -ConfigFile ${NUGET_CONFIG}
|
||||
VERBATIM)
|
||||
|
||||
include_directories(BEFORE "${DML_PACKAGE_DIR}/include")
|
||||
add_custom_target(RESTORE_PACKAGES ALL DEPENDS ${DML_PACKAGE_DIR}/bin/x64/DirectML.lib ${DML_PACKAGE_DIR}/bin/x86/DirectML.lib)
|
||||
add_custom_target(RESTORE_PACKAGES ALL DEPENDS ${DML_PACKAGE_DIR}/bin/x64-win/DirectML.lib ${DML_PACKAGE_DIR}/bin/x86-win/DirectML.lib)
|
||||
add_dependencies(RESTORE_PACKAGES nuget)
|
||||
else()
|
||||
include_directories(${dml_INCLUDE_DIR})
|
||||
|
|
|
|||
|
|
@ -776,7 +776,7 @@ if (onnxruntime_USE_DML)
|
|||
add_custom_command(TARGET onnxruntime_providers_dml
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${DML_PACKAGE_DIR}/bin/${onnxruntime_target_platform}/${file}" $<TARGET_FILE_DIR:onnxruntime_providers_dml>)
|
||||
"${DML_PACKAGE_DIR}/bin/${onnxruntime_target_platform}-win/${file}" $<TARGET_FILE_DIR:onnxruntime_providers_dml>)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
|
|
@ -785,8 +785,8 @@ if (onnxruntime_USE_DML)
|
|||
target_link_libraries(${target} PRIVATE DirectML)
|
||||
else()
|
||||
add_dependencies(${target} RESTORE_PACKAGES)
|
||||
target_link_libraries(${target} PRIVATE "${DML_PACKAGE_DIR}/bin/${onnxruntime_target_platform}/DirectML.lib")
|
||||
target_compile_definitions(${target} PRIVATE DML_TARGET_VERSION_USE_LATEST)
|
||||
target_link_libraries(${target} PRIVATE "${DML_PACKAGE_DIR}/bin/${onnxruntime_target_platform}-win/DirectML.lib")
|
||||
target_compile_definitions(${target} PRIVATE DML_TARGET_VERSION_USE_LATEST)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ if (onnxruntime_USE_DML)
|
|||
add_custom_command(
|
||||
TARGET onnxruntime_pybind11_state POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${DML_PACKAGE_DIR}/bin/${onnxruntime_target_platform}/${DML_SHARED_LIB}
|
||||
${DML_PACKAGE_DIR}/bin/${onnxruntime_target_platform}-win/${DML_SHARED_LIB}
|
||||
$<TARGET_FILE_DIR:${test_data_target}>/onnxruntime/capi/
|
||||
)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -13,17 +13,6 @@
|
|||
<RuntimesDirectory Condition="'$(RuntimesDirectory)' == ''">$(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native</RuntimesDirectory>
|
||||
<WindowsAIBinary>$(RuntimesDirectory)\Microsoft.AI.MachineLearning.dll</WindowsAIBinary>
|
||||
<OnnxRuntimeBinary>$(RuntimesDirectory)\onnxruntime.dll</OnnxRuntimeBinary>
|
||||
<DirectMLBinary>$(RuntimesDirectory)\directml.dll</DirectMLBinary>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<MLBinaries>$(WindowsAIBinary);$(OnnxRuntimeBinary);$(DirectMLBinary)</MLBinaries>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(WindowsAI-Platform)' == x64 OR '$(WindowsAI-Platform)' == x86">
|
||||
<MLBinaries>$(WindowsAIBinary);$(OnnxRuntimeBinary);$(DirectMLBinary)</MLBinaries>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(OutputType)' == 'AppContainerExe' OR '$(WindowsAI-Platform)' == arm OR '$(WindowsAI-Platform)' == arm64">
|
||||
<MLBinaries>$(WindowsAIBinary);$(OnnxRuntimeBinary)</MLBinaries>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="CopyMLBinaries" BeforeTargets="CoreBuild">
|
||||
|
|
@ -31,6 +20,6 @@
|
|||
<WindowsAIBinplaceMessage>Binplacing WindowsAI binaries: {0} and {1}.</WindowsAIBinplaceMessage>
|
||||
</PropertyGroup>
|
||||
<Message Text="$([System.String]::Format('$(WindowsAIBinplaceMessage)', '$(WindowsAIBinary)', '$(OnnxRuntimeBinary)'))" />
|
||||
<Copy SkipUnchangedFiles="True" SourceFiles="$(MLBinaries)" DestinationFolder="$(OutDir)" />
|
||||
<Copy SkipUnchangedFiles="True" SourceFiles="$(WindowsAIBinary);$(OnnxRuntimeBinary)" DestinationFolder="$(OutDir)" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -13,11 +13,6 @@
|
|||
Description="Suppresses binplacing the onnxruntime.dll from the Mirosoft.AI.MachineLearning NuGet distribution."
|
||||
Category="General" />
|
||||
|
||||
<BoolProperty Name="DisableDirectMLDllCopy"
|
||||
DisplayName="Disable directml.dll copy on build"
|
||||
Description="Suppresses binplacing the directml.dll from the Mirosoft.AI.MachineLearning NuGet distribution."
|
||||
Category="General" />
|
||||
|
||||
<BoolProperty Name="UseWindowsMLStaticRuntime"
|
||||
DisplayName="Use a dll that links statically to runtimes"
|
||||
Description="Use a larger DLL that doesn't depend on installed versions of the vcruntime and CRT."
|
||||
|
|
|
|||
|
|
@ -12,4 +12,11 @@
|
|||
<ItemGroup>
|
||||
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)\Microsoft.AI.MachineLearning.Rules.Project.xml"/>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Label="Globals">
|
||||
<!-- Assume apps using the WinML package only want the DirectML binaries (no need for a build dependency). -->
|
||||
<Microsoft_AI_DirectML_SkipDebugLayerCopy>true</Microsoft_AI_DirectML_SkipDebugLayerCopy>
|
||||
<Microsoft_AI_DirectML_SkipLink>true</Microsoft_AI_DirectML_SkipLink>
|
||||
<Microsoft_AI_DirectML_SkipIncludeDir>true</Microsoft_AI_DirectML_SkipIncludeDir>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -15,25 +15,14 @@
|
|||
<PropertyGroup Condition="'$(DisableOnnxRuntimeDllCopy)' != 'true'">
|
||||
<OnnxRuntimeBinary Condition="'$(OnnxRuntimeBinary)' == ''">$(RuntimesDirectory)\$(WindowsAIBinarySubfolder)onnxruntime.dll</OnnxRuntimeBinary>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(DisableDirectMLDllCopy)' != 'true'">
|
||||
<DirectMLBinary Condition="'$(DirectMLBinary)' == ''">$(RuntimesDirectory)\directml.dll</DirectMLBinary>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="$(MSBuildThisFileDirectory)\..\..\lib\uap\Microsoft.AI.MachineLearning.winmd">
|
||||
<Implementation>$(WindowsAIBinary)</Implementation>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(WindowsAI-Platform)' == x64 OR '$(WindowsAI-Platform)' == x86">
|
||||
<MLBinaries>$(WindowsAIBinary);$(OnnxRuntimeBinary);$(DirectMLBinary)</MLBinaries>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(OutputType)' == 'AppContainerExe' OR '$(WindowsAI-Platform)' == arm OR '$(WindowsAI-Platform)' == arm64">
|
||||
<MLBinaries>$(WindowsAIBinary);$(OnnxRuntimeBinary)</MLBinaries>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ReferenceCopyLocalPaths Include="$(MLBinaries)" />
|
||||
<ReferenceCopyLocalPaths Include="$(WindowsAIBinary);$(OnnxRuntimeBinary)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -113,14 +113,6 @@
|
|||
CopyToOutputDirectory="Always"
|
||||
Visible="false"
|
||||
/>
|
||||
<None Include="$(NativeBuildOutputDir)\DirectML.dll"
|
||||
Condition="Exists('$(NativeBuildOutputDir)\DirectML.dll')
|
||||
And '$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.DirectML'"
|
||||
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
||||
Pack="false"
|
||||
CopyToOutputDirectory="Always"
|
||||
Visible="false"
|
||||
/>
|
||||
<None Include="$(NativeBuildOutputDir)\dnnl.dll"
|
||||
Condition="Exists('$(NativeBuildOutputDir)\dnnl.dll')"
|
||||
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
||||
|
|
|
|||
|
|
@ -29,7 +29,13 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OnnxRuntimeBinary>$(MSBuildThisFileDirectory)..\..\runtimes\win-$(EnginePlatform)\native\onnxruntime.dll</OnnxRuntimeBinary>
|
||||
<DirectMLBinary Condition="Exists('$(MSBuildThisFileDirectory)..\..\runtimes\win-$(EnginePlatform)\native\directml.dll')">$(MSBuildThisFileDirectory)..\..\runtimes\win-$(EnginePlatform)\native\directml.dll</DirectMLBinary>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Assume apps using the Microsoft.ML.OnnxRuntime.DirectML package only want the DirectML binaries (no need for a build dependency). -->
|
||||
<PropertyGroup Label="Globals" Condition="Exists('$(MSBuildThisFileDirectory)include\dml_provider_factory.h')">
|
||||
<Microsoft_AI_DirectML_SkipDebugLayerCopy>true</Microsoft_AI_DirectML_SkipDebugLayerCopy>
|
||||
<Microsoft_AI_DirectML_SkipLink>true</Microsoft_AI_DirectML_SkipLink>
|
||||
<Microsoft_AI_DirectML_SkipIncludeDir>true</Microsoft_AI_DirectML_SkipIncludeDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ When used standalone, the DirectML API is a low-level DirectX 12 library and is
|
|||
|
||||
The *DirectML Execution Provider* is an optional component of ONNX Runtime that uses DirectML to accelerate inference of ONNX models. The DirectML execution provider is capable of greatly improving evaluation time of models using commodity GPU hardware, without sacrificing broad hardware support or requiring vendor-specific extensions to be installed.
|
||||
|
||||
The DirectML Execution Provider currently uses DirectML version 1.3.0.
|
||||
The DirectML Execution Provider currently uses DirectML version 1.4.0.
|
||||
|
||||
## Table of contents
|
||||
|
||||
|
|
@ -15,11 +15,12 @@ The DirectML Execution Provider currently uses DirectML version 1.3.0.
|
|||
- [Minimum requirements](#minimum-requirements)
|
||||
- [Building from source](#building-from-source)
|
||||
- [Using the DirectML execution provider](#using-the-directml-execution-provider)
|
||||
- [`OrtSessionOptionsAppendExecutionProvider_DML` function](#ortsessionoptionsappendexecutionproviderdml-function)
|
||||
- [`OrtSessionOptionsAppendExecutionProviderEx_DML` function](#ortsessionoptionsappendexecutionproviderexdml-function)
|
||||
- [`OrtSessionOptionsAppendExecutionProvider_DML` function](#ortsessionoptionsappendexecutionprovider_dml-function)
|
||||
- [`OrtSessionOptionsAppendExecutionProviderEx_DML` function](#ortsessionoptionsappendexecutionproviderex_dml-function)
|
||||
- [ONNX opset support](#onnx-opset-support)
|
||||
- [Multi-threading and supported session options](#multi-threading-and-supported-session-options)
|
||||
- [Samples](#samples)
|
||||
- [Performance best practices](#performance-best-practices)
|
||||
- [See also](#see-also)
|
||||
|
||||
## Minimum requirements
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="DirectML" version="1.3.0" targetFramework="native" />
|
||||
<package id="Microsoft.AI.DirectML" version="1.4.0" targetFramework="native" />
|
||||
<package id="GoogleTestAdapter" version="0.17.1" targetFramework="net46" />
|
||||
</packages>
|
||||
|
|
|
|||
|
|
@ -200,8 +200,6 @@ jobs:
|
|||
move win-x86\runtimes\win-x86\native\onnxruntime.dll %%~ni\runtimes\win-x86\native\onnxruntime.dll
|
||||
move win-x86\runtimes\win-x86\native\onnxruntime.lib %%~ni\runtimes\win-x86\native\onnxruntime.lib
|
||||
move win-x86\runtimes\win-x86\native\onnxruntime.pdb %%~ni\runtimes\win-x86\native\onnxruntime.pdb
|
||||
move win-x86\runtimes\win-x86\native\directml.dll %%~ni\runtimes\win-x86\native\DirectML.dll
|
||||
move win-x86\runtimes\win-x86\native\directml.pdb %%~ni\runtimes\win-x86\native\DirectML.pdb
|
||||
|
||||
pushd %%~ni
|
||||
zip -r ..\%%~ni.zip .
|
||||
|
|
|
|||
|
|
@ -363,7 +363,6 @@ jobs:
|
|||
Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'onnxruntime.lib')) $x86_runtime_path_new
|
||||
Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'microsoft.ai.machinelearning.dll')) $x86_runtime_path_new
|
||||
Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'microsoft.ai.machinelearning.lib')) $x86_runtime_path_new
|
||||
Copy-Item ([System.IO.Path]::Combine($x86_runtime_path_old, 'directml.dll')) $x86_runtime_path_new
|
||||
|
||||
Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'onnxruntime.dll')) $arm64_runtime_path_new
|
||||
Copy-Item ([System.IO.Path]::Combine($arm64_runtime_path_old, 'onnxruntime.lib')) $arm64_runtime_path_new
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ def generate_repo_url(list, repo_url, commit_id):
|
|||
|
||||
|
||||
def generate_dependencies(list, package_name, version):
|
||||
dml_dependency = '<dependency id="Microsoft.AI.DirectML" version="1.4.0"/>'
|
||||
|
||||
if (package_name == 'Microsoft.AI.MachineLearning'):
|
||||
list.append('<dependencies>')
|
||||
|
||||
|
|
@ -96,23 +98,41 @@ def generate_dependencies(list, package_name, version):
|
|||
list.append('</group>')
|
||||
# UAP10.0.16299, This is the earliest release of the OS that supports .NET Standard apps
|
||||
list.append('<group targetFramework="UAP10.0.16299">')
|
||||
list.append(dml_dependency)
|
||||
list.append('</group>')
|
||||
# Support Native C++
|
||||
list.append('<group targetFramework="native">')
|
||||
list.append(dml_dependency)
|
||||
list.append('</group>')
|
||||
|
||||
list.append('</dependencies>')
|
||||
else:
|
||||
include_dml = package_name == 'Microsoft.ML.OnnxRuntime.DirectML'
|
||||
|
||||
list.append('<dependencies>')
|
||||
# Support .Net Core
|
||||
list.append('<group targetFramework="NETCOREAPP">')
|
||||
list.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
|
||||
if include_dml:
|
||||
list.append(dml_dependency)
|
||||
list.append('</group>')
|
||||
# Support .Net Standard
|
||||
list.append('<group targetFramework="NETSTANDARD">')
|
||||
list.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
|
||||
if include_dml:
|
||||
list.append(dml_dependency)
|
||||
list.append('</group>')
|
||||
# Support .Net Framework
|
||||
list.append('<group targetFramework="NETFRAMEWORK">')
|
||||
list.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
|
||||
if include_dml:
|
||||
list.append(dml_dependency)
|
||||
list.append('</group>')
|
||||
# Support Native C++
|
||||
if include_dml:
|
||||
list.append('<group targetFramework="native">')
|
||||
list.append(dml_dependency)
|
||||
list.append('</group>')
|
||||
|
||||
list.append('</dependencies>')
|
||||
|
||||
|
|
@ -289,14 +309,6 @@ def generate_files(list, args):
|
|||
'libonnxruntime.so') + '" target="runtimes\\linux-' + args.target_architecture +
|
||||
'\\native" />')
|
||||
|
||||
if includes_directml:
|
||||
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, 'DirectML.dll') +
|
||||
runtimes + ' />')
|
||||
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, 'DirectML.pdb') +
|
||||
runtimes + ' />')
|
||||
files_list.append('<file src=' + '"' + os.path.join(args.packages_path, 'DirectML.1.3.0\\LICENSE.txt') +
|
||||
'" target="DirectML_LICENSE.txt" />')
|
||||
|
||||
if includes_winml:
|
||||
# Process microsoft.ai.machinelearning import lib, dll, and pdb
|
||||
files_list.append('<file src=' + '"' +
|
||||
|
|
|
|||
Loading…
Reference in a new issue