mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
This change adds a new execution provider powered by [DirectML](https://aka.ms/DirectML). DirectML is a high-performance, hardware-accelerated DirectX 12 library for machine learning on Windows. DirectML provides GPU acceleration for common machine learning tasks across a broad range of supported hardware and drivers. 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. **Note** that the DML EP code was moved verbatim from the existing WindowsAI project, which is why it doesn't yet conform to the onnxruntime coding style. This is something that can be fixed later; we would like to keep formatting/whitespace changes to a minimum for the time being to make it easier to port fixes from WindowsAI to ORT during this transition. Summary of changes: * Initial commit of DML EP files under onnxruntime/core/providers/dml * Add cmake entries for building the DML EP and for pulling down the DirectML redist using nuget * Add a submodule dependency on the Windows Implementation Library (WIL) * Add docs under docs/execution_providers/DirectML-ExecutionProvider.md * Add support for DML EP to provider tests and perf tests * Add support for DML EP to fns_candy_style_transfer sample * Add entries to the C ABI for instantiating the DML EP
59 lines
2.3 KiB
CMake
59 lines
2.3 KiB
CMake
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
|
|
file(GLOB_RECURSE onnxruntime_graph_src CONFIGURE_DEPENDS
|
|
"${ONNXRUNTIME_INCLUDE_DIR}/core/graph/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/graph/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/graph/*.cc"
|
|
)
|
|
|
|
if (onnxruntime_DISABLE_CONTRIB_OPS)
|
|
list(REMOVE_ITEM onnxruntime_graph_src
|
|
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/graph/contrib_ops/*.cc"
|
|
)
|
|
endif()
|
|
|
|
if(NOT onnxruntime_USE_AUTOML)
|
|
list(REMOVE_ITEM onnxruntime_graph_src
|
|
"${ONNXRUNTIME_ROOT}/core/graph/automl_ops/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/graph/automl_ops/*.cc"
|
|
)
|
|
endif()
|
|
|
|
if(NOT onnxruntime_USE_DML)
|
|
list(REMOVE_ITEM onnxruntime_graph_src
|
|
"${ONNXRUNTIME_ROOT}/core/graph/dml_ops/*.h"
|
|
"${ONNXRUNTIME_ROOT}/core/graph/dml_ops/*.cc"
|
|
)
|
|
endif()
|
|
|
|
file(GLOB_RECURSE onnxruntime_ir_defs_src CONFIGURE_DEPENDS
|
|
"${ONNXRUNTIME_ROOT}/core/defs/*.cc"
|
|
)
|
|
|
|
add_library(onnxruntime_graph ${onnxruntime_graph_src} ${onnxruntime_ir_defs_src})
|
|
add_dependencies(onnxruntime_graph onnx_proto)
|
|
onnxruntime_add_include_to_target(onnxruntime_graph onnxruntime_common onnx onnx_proto protobuf::libprotobuf)
|
|
|
|
target_include_directories(onnxruntime_graph PRIVATE ${ONNXRUNTIME_ROOT})
|
|
set_target_properties(onnxruntime_graph PROPERTIES FOLDER "ONNXRuntime")
|
|
set_target_properties(onnxruntime_graph PROPERTIES LINKER_LANGUAGE CXX)
|
|
install(DIRECTORY ${PROJECT_SOURCE_DIR}/../include/onnxruntime/core/graph DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/onnxruntime/core)
|
|
source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_graph_src} ${onnxruntime_ir_defs_src})
|
|
|
|
if (WIN32)
|
|
set(onnxruntime_graph_static_library_flags
|
|
-IGNORE:4221 # LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
|
|
)
|
|
|
|
set_target_properties(onnxruntime_graph PROPERTIES
|
|
STATIC_LIBRARY_FLAGS "${onnxruntime_graph_static_library_flags}")
|
|
|
|
target_compile_options(onnxruntime_graph PRIVATE
|
|
/EHsc # exception handling - C++ may throw, extern "C" will not
|
|
)
|
|
|
|
# Add Code Analysis properties to enable C++ Core checks. Have to do it via a props file include.
|
|
set_target_properties(onnxruntime_graph PROPERTIES VS_USER_PROPS ${PROJECT_SOURCE_DIR}/EnableVisualStudioCodeAnalysis.props)
|
|
endif()
|