diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f5d98495ef..a39b8aff73 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -253,7 +253,7 @@ if (MSVC) else() if(onnxruntime_BUILD_FOR_NATIVE_MACHINE) string(APPEND CMAKE_CXX_FLAGS " -march=native -mtune=native") - string(APPEND CMAKE_C_FLAGS " -march=native -mtune=native") + string(APPEND CMAKE_C_FLAGS " -march=native -mtune=native") elseif(onnxruntime_USE_AVX) string(APPEND CMAKE_CXX_FLAGS " -mavx") string(APPEND CMAKE_C_FLAGS " -mavx") @@ -277,7 +277,7 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "iOSCross") message("Adding flags for ios builds") if (CMAKE_OSX_ARCHITECTURES STREQUAL "arm64") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target arm64-apple-darwin-macho") - elseif (CMAKE_OSX_ARCHITECTURES STREQUAL "arm") + elseif (CMAKE_OSX_ARCHITECTURES STREQUAL "arm") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -target armv7a-apple-darwin-macho") endif() endif() @@ -874,7 +874,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Android") endif() if(WIN32) - list(APPEND onnxruntime_EXTERNAL_LIBRARIES Shlwapi) + list(APPEND onnxruntime_EXTERNAL_LIBRARIES ${SYS_PATH_LIB} Shlwapi) list(APPEND onnxruntime_EXTERNAL_LIBRARIES debug Dbghelp) else() list(APPEND onnxruntime_EXTERNAL_LIBRARIES nsync_cpp) diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index f29ed82cf3..11d8e031e0 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -447,10 +447,13 @@ if (onnxruntime_USE_DML) endif() function(target_add_dml target) - if (NOT onnxruntime_USE_CUSTOM_DIRECTML) - target_link_libraries(${target} PRIVATE "${DML_PACKAGE_DIR}/bin/${onnxruntime_target_platform}/DirectML.lib") + if (onnxruntime_USE_CUSTOM_DIRECTML) + 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") endif() + target_link_options(${target} PUBLIC /DELAYLOAD:directml.dll /DELAYLOAD:dxgi.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:d3d12.dll) endfunction() target_add_dml(onnxruntime_providers_dml) diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index fbe632fd50..b11086a208 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -644,7 +644,9 @@ target_include_directories(onnxruntime_perf_test PRIVATE ${onnx_test_runner_src_ ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/onnx) if (WIN32) target_compile_options(onnxruntime_perf_test PRIVATE ${disabled_warnings}) - SET(SYS_PATH_LIB shlwapi) + if (NOT DEFINED SYS_PATH_LIB) + set(SYS_PATH_LIB shlwapi) + endif() endif() if (onnxruntime_BUILD_SHARED_LIB) diff --git a/cmake/test_dxcore.cpp b/cmake/test_dxcore.cpp new file mode 100644 index 0000000000..22cbf49a79 --- /dev/null +++ b/cmake/test_dxcore.cpp @@ -0,0 +1,8 @@ +// CMake's CHECK_INCLUDE_FILE_CXX macro can't be used because it doesn't check the machine's SDK folder +#if not __has_include("dxcore.h") +#error +#endif + +int main() { + return 0; +} diff --git a/cmake/winml.cmake b/cmake/winml.cmake index a4b7a8f952..f87fda11e5 100644 --- a/cmake/winml.cmake +++ b/cmake/winml.cmake @@ -347,7 +347,14 @@ add_dependencies(winml_lib_image winml_api_native) add_dependencies(winml_lib_image winml_api_native_internal) # Link libraries -target_link_libraries(winml_lib_image PRIVATE wil winml_lib_common) +target_link_libraries(winml_lib_image PRIVATE dxgi d3d11 d3d12 wil winml_lib_common) + +get_target_property(winml_lib_image_include_directories winml_lib_image INCLUDE_DIRECTORIES) +try_compile(has_dxcore "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/test_dxcore.cpp" CMAKE_FLAGS -DLINK_DIRECTORIES="${winml_lib_image_include_directories}") +if (has_dxcore) + target_link_libraries(winml_lib_image PRIVATE dxcore) +endif() + if (onnxruntime_USE_DML) target_add_dml(winml_lib_image) endif(onnxruntime_USE_DML) @@ -584,13 +591,11 @@ set_target_properties(winml_dll PROPERTIES OUTPUT_NAME ${output_name}) -if (onnxruntime_USE_DML) - set(delayload_dml "/DELAYLOAD:directml.dll") -endif(onnxruntime_USE_DML) - set(os_component_link_flags_list ${os_component_link_flags}) separate_arguments(os_component_link_flags_list) -target_link_options(winml_dll PRIVATE /DEF:${WINML_DIR}/winml.def ${os_component_link_flags_list} /DELAYLOAD:api-ms-win-core-libraryloader-l1-2-1.dll /DELAYLOAD:api-ms-win-core-threadpool-legacy-l1-1-0.dll /DELAYLOAD:api-ms-win-core-processtopology-obsolete-l1-1-0.dll /DELAYLOAD:api-ms-win-core-kernel32-legacy-l1-1-0.dll /DELAYLOAD:d3d12.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:dxgi.dll ${delayload_dml}) + +target_link_options(winml_dll PRIVATE /DEF:${WINML_DIR}/winml.def ${os_component_link_flags_list} /DELAYLOAD:api-ms-win-core-libraryloader-l1-2-1.dll /DELAYLOAD:api-ms-win-core-threadpool-legacy-l1-1-0.dll /DELAYLOAD:api-ms-win-core-processtopology-obsolete-l1-1-0.dll /DELAYLOAD:api-ms-win-core-kernel32-legacy-l1-1-0.dll /DELAYLOAD:d3d12.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:dxgi.dll) + if (EXISTS ${dxcore_header}) target_link_options(winml_dll PRIVATE /DELAYLOAD:ext-ms-win-dxcore-l1-*.dll) @@ -615,6 +620,7 @@ target_link_libraries(winml_dll PRIVATE winml_lib_image) target_link_libraries(winml_dll PRIVATE winml_lib_ort) target_link_libraries(winml_dll PRIVATE winml_lib_telemetry) target_link_libraries(winml_dll PRIVATE delayimp.lib) +target_link_libraries(winml_dll PRIVATE RuntimeObject.lib) # Any project that links in debug_alloc.obj needs this lib. # unresolved external symbol __imp_SymSetOptions diff --git a/winml/lib/Api.Image/ConverterResourceStore.cpp b/winml/lib/Api.Image/ConverterResourceStore.cpp index 4927a911ef..c293974f20 100644 --- a/winml/lib/Api.Image/ConverterResourceStore.cpp +++ b/winml/lib/Api.Image/ConverterResourceStore.cpp @@ -96,4 +96,4 @@ void ConverterResourceStore::EvictOldestPoolObject() { // Remove the oldest item from the cache m_objects.erase(oldestIt); -} \ No newline at end of file +} diff --git a/winml/lib/Api.Image/ImageConversionHelpers.cpp b/winml/lib/Api.Image/ImageConversionHelpers.cpp index c8aa181045..6a9de03937 100644 --- a/winml/lib/Api.Image/ImageConversionHelpers.cpp +++ b/winml/lib/Api.Image/ImageConversionHelpers.cpp @@ -4,6 +4,8 @@ #include "pch.h" #include "inc/ImageConversionHelpers.h" +#include + using namespace Microsoft::WRL; using namespace Windows::Graphics::DirectX::Direct3D11; diff --git a/winml/lib/Api.Image/inc/ConverterResourceStore.h b/winml/lib/Api.Image/inc/ConverterResourceStore.h index 9162d334f2..18c2eaf137 100644 --- a/winml/lib/Api.Image/inc/ConverterResourceStore.h +++ b/winml/lib/Api.Image/inc/ConverterResourceStore.h @@ -3,6 +3,7 @@ #pragma once +#include #include #include "VideoFrameToTensorConverter.h" #include "TensorToVideoFrameConverter.h" @@ -115,4 +116,5 @@ class PoolObjectWrapper { std::shared_ptr m_resources; }; -} // namespace _winml \ No newline at end of file +} // namespace _winml + diff --git a/winml/lib/Api.Ort/OnnxruntimeCpuSessionBuilder.cpp b/winml/lib/Api.Ort/OnnxruntimeCpuSessionBuilder.cpp index aee8a7e69a..fc59fa1dac 100644 --- a/winml/lib/Api.Ort/OnnxruntimeCpuSessionBuilder.cpp +++ b/winml/lib/Api.Ort/OnnxruntimeCpuSessionBuilder.cpp @@ -3,6 +3,8 @@ #include "pch.h" +#include + #include "OnnxruntimeCpuSessionBuilder.h" #include "OnnxruntimeEngine.h" #include "OnnxruntimeErrors.h" diff --git a/winml/lib/Api.Ort/OnnxruntimeEngine.h b/winml/lib/Api.Ort/OnnxruntimeEngine.h index 37e8affb3d..b4a85a95c9 100644 --- a/winml/lib/Api.Ort/OnnxruntimeEngine.h +++ b/winml/lib/Api.Ort/OnnxruntimeEngine.h @@ -4,6 +4,7 @@ #include "iengine.h" #include +#include namespace _winml { @@ -152,4 +153,4 @@ class OnnxruntimeEngineFactory : public Microsoft::WRL::RuntimeClass< std::mutex mutex_; }; -} // namespace _winml \ No newline at end of file +} // namespace _winml diff --git a/winml/lib/Common/inc/winrt_headers.h b/winml/lib/Common/inc/winrt_headers.h index ed8de42124..a07f086084 100644 --- a/winml/lib/Common/inc/winrt_headers.h +++ b/winml/lib/Common/inc/winrt_headers.h @@ -25,4 +25,4 @@ #include CREATE_NATIVE_HEADER() #include CREATE_NATIVE_INTERNAL_HEADER() -#include "Errors.h" \ No newline at end of file +#include "Errors.h" diff --git a/winml/test/common/googleTestMacros.h b/winml/test/common/googleTestMacros.h index 19e054b095..ca66160d75 100644 --- a/winml/test/common/googleTestMacros.h +++ b/winml/test/common/googleTestMacros.h @@ -100,8 +100,10 @@ _no_gpu_tests == RuntimeParameters::Parameters.end() || _no_gpu_tests->second == "0" #endif -#define SKIP_EDGECORE \ - if (auto isEdgeCore = RuntimeParameters::Parameters.find("EdgeCore"); \ - isEdgeCore != RuntimeParameters::Parameters.end() && isEdgeCore->second != "0") { \ - WINML_SKIP_TEST("Test can't be run in EdgeCore"); \ - } +#define SKIP_EDGECORE \ + do { \ + if (auto is_edge_core = RuntimeParameters::Parameters.find("EdgeCore"); \ + is_edge_core != RuntimeParameters::Parameters.end() && is_edge_core->second != "0") { \ + WINML_SKIP_TEST("Test can't be run in EdgeCore"); \ + } \ + } while (0) diff --git a/winml/test/common/taefTestMacros.h b/winml/test/common/taefTestMacros.h index 54bd4de0ca..94e89ecccd 100644 --- a/winml/test/common/taefTestMacros.h +++ b/winml/test/common/taefTestMacros.h @@ -74,9 +74,9 @@ using namespace WEX::TestExecution; #else #define GPUTEST \ do { \ - bool noGPUTests; \ - if (SUCCEEDED(RuntimeParameters::TryGetValue(L"noGPUtests", noGPUTests)) && noGPUTests) { \ - WINML_SKIP_TEST("This test is disabled by the noGPUTests runtime parameter."); \ + bool no_gpu_tests; \ + if (SUCCEEDED(RuntimeParameters::TryGetValue(L"noGPUtests", no_gpu_tests)) && no_gpu_tests) { \ + WINML_SKIP_TEST("This test is disabled by the no_gpu_tests runtime parameter."); \ return; \ } \ } while (0) diff --git a/winml/test/concurrency/ConcurrencyTests.cpp b/winml/test/concurrency/ConcurrencyTests.cpp index aac227c92c..623224af0e 100644 --- a/winml/test/concurrency/ConcurrencyTests.cpp +++ b/winml/test/concurrency/ConcurrencyTests.cpp @@ -252,11 +252,11 @@ void MultiThreadMultiSessionOnDevice(const LearningModelDevice& device) { } void MultiThreadMultiSession() { - MultiThreadMultiSessionOnDevice(LearningModelDeviceKind::Cpu); + MultiThreadMultiSessionOnDevice(LearningModelDevice(LearningModelDeviceKind::Cpu)); } void MultiThreadMultiSessionGpu() { - MultiThreadMultiSessionOnDevice(LearningModelDeviceKind::DirectX); + MultiThreadMultiSessionOnDevice(LearningModelDevice(LearningModelDeviceKind::DirectX)); } // Create different sessions for each thread, and evaluate @@ -321,11 +321,11 @@ void MultiThreadSingleSessionOnDevice(const LearningModelDevice& device) { } void MultiThreadSingleSession() { - MultiThreadSingleSessionOnDevice(LearningModelDeviceKind::Cpu); + MultiThreadSingleSessionOnDevice(LearningModelDevice(LearningModelDeviceKind::Cpu)); } void MultiThreadSingleSessionGpu() { - MultiThreadSingleSessionOnDevice(LearningModelDeviceKind::DirectX); + MultiThreadSingleSessionOnDevice(LearningModelDevice(LearningModelDeviceKind::DirectX)); } }