Merge user/ticastro/fix-wai-build

This commit is contained in:
Jeff Bloomfield 2020-04-17 14:10:50 -07:00
parent 822883314e
commit 11baa4b56d
14 changed files with 56 additions and 28 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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)

8
cmake/test_dxcore.cpp Normal file
View file

@ -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;
}

View file

@ -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

View file

@ -96,4 +96,4 @@ void ConverterResourceStore::EvictOldestPoolObject() {
// Remove the oldest item from the cache
m_objects.erase(oldestIt);
}
}

View file

@ -4,6 +4,8 @@
#include "pch.h"
#include "inc/ImageConversionHelpers.h"
#include <winrt/Windows.Graphics.DirectX.Direct3D11.h>
using namespace Microsoft::WRL;
using namespace Windows::Graphics::DirectX::Direct3D11;

View file

@ -3,6 +3,7 @@
#pragma once
#include <mutex>
#include <winrt/windows.media.h>
#include "VideoFrameToTensorConverter.h"
#include "TensorToVideoFrameConverter.h"
@ -115,4 +116,5 @@ class PoolObjectWrapper {
std::shared_ptr<ConverterResources> m_resources;
};
} // namespace _winml
} // namespace _winml

View file

@ -3,6 +3,8 @@
#include "pch.h"
#include <thread>
#include "OnnxruntimeCpuSessionBuilder.h"
#include "OnnxruntimeEngine.h"
#include "OnnxruntimeErrors.h"

View file

@ -4,6 +4,7 @@
#include "iengine.h"
#include <memory>
#include <mutex>
namespace _winml {
@ -152,4 +153,4 @@ class OnnxruntimeEngineFactory : public Microsoft::WRL::RuntimeClass<
std::mutex mutex_;
};
} // namespace _winml
} // namespace _winml

View file

@ -25,4 +25,4 @@
#include CREATE_NATIVE_HEADER()
#include CREATE_NATIVE_INTERNAL_HEADER()
#include "Errors.h"
#include "Errors.h"

View file

@ -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)

View file

@ -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)

View file

@ -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));
}
}