* Remove APIs unavailable in Store in #8349, #8178, #8065

* Add UWP stubs of C runtime functions

* Remove UWP incompatible tests from UWP build

* Remove incompatible tests from Store

* Use UWP stubs in store only

* Skip partition check outside of Windows

* Remove unused WRL include

* Workaround Windows header not including what it uses

* Fix precompiled header name clash

* Workaround SDK bugs

* DXCore workaround in Win7

* Fix warning

* Fix more warnings

* Bump WinML to target Windows 8

* Fix more warnings

* Remove unnecessary workarounds
This commit is contained in:
Tiago Koji Castro Shibata 2021-08-10 15:19:30 -07:00 коммит произвёл GitHub
Родитель 064a385b59
Коммит 53e7831b53
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
66 изменённых файлов: 161 добавлений и 99 удалений

Просмотреть файл

@ -260,12 +260,6 @@ if(NOT WIN32)
message(WARNING "Instrument is only supported on Windows now")
set(onnxruntime_ENABLE_INSTRUMENT OFF)
endif()
else()
if(WINDOWS_STORE)
# cmake/external/protobuf/src/google/protobuf/compiler/subprocess.cc and onnxruntime/core/platform/windows/env.cc call a bunch of Win32 APIs.
# For now, we'll set the API family to desktop globally to expose Win32 symbols in headers; this must be fixed!
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/FI${CMAKE_CURRENT_SOURCE_DIR}/set_winapi_family_desktop.h>")
endif()
endif()
if(onnxruntime_USE_OPENMP)
@ -802,7 +796,7 @@ endif()
# Adding pytorch CPU info library
# TODO do we have to add target_include_directories to each project that uses this?
if(MSVC AND (( CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM.*|arm.*)$" ) OR (CMAKE_GENERATOR_PLATFORM MATCHES "^(ARM.*|arm.*)$" ) ))
if(WINDOWS_STORE OR (MSVC AND (( CMAKE_SYSTEM_PROCESSOR MATCHES "^(ARM.*|arm.*)$" ) OR (CMAKE_GENERATOR_PLATFORM MATCHES "^(ARM.*|arm.*)$" ) )) )
# cpuinfo fail to compile with windows arm.
else()
set(PYTORCH_CPUINFO_DIR external/pytorch_cpuinfo)
@ -1693,8 +1687,8 @@ if (WIN32)
if (WINDOWS_STORE)
# Setting WINAPI_FAMILY, WINVER and _WIN32_WINNT restrict the APIs exposed in Windows headers to those available
# in store or desktop, and that support at least the version of Windows specified
# add_compile_definitions(WINAPI_FAMILY=2)
add_compile_definitions(WINVER=0x0A00 _WIN32_WINNT=0x0A00) # Support Windows 10
add_compile_definitions(WINAPI_FAMILY=2) # Windows Store app
add_compile_definitions(WINVER=0x0A00 _WIN32_WINNT=0x0A00 NTDDI_VERSION=0x0A000000) # Support Windows 10 or newer
# /ZW adds /FUplatform.winmd and /FUwindows.winmd. windows.winmd, in turn, overrides the include path for
# the cppwinrt headers, which we set to use the WinML built ones.
# Instead, we use /ZW:nostdlib and force include platform.winml only.
@ -1703,10 +1697,12 @@ if (WIN32)
link_directories("${msvc_path}/lib/${onnxruntime_target_platform}/store")
add_link_options(/APPCONTAINER)
else()
add_compile_definitions(WINVER=0x0601) # Support Windows 7 and newer
# add_compile_definitions(WINAPI_FAMILY=3)
# FIXME adding _WIN32_WINNT=0x0601 and WINAPI_FAMILY is desirable. However, it hides some symbols that are used in WRL
# headers and breaks the build of WinML. We should have separate WINVER/_WIN32_WINNT definitions for WinML
add_compile_definitions(WINAPI_FAMILY=100) # Desktop app
if (onnxruntime_USE_WINML)
add_compile_definitions(WINVER=0x0602 _WIN32_WINNT=0x0602 NTDDI_VERSION=0x06020000) # Support Windows 7 and newer
else()
add_compile_definitions(WINVER=0x0601 _WIN32_WINNT=0x0601 NTDDI_VERSION=0x06010000) # Support Windows 7 and newer
endif()
endif()
endif()

Просмотреть файл

@ -229,7 +229,7 @@ endif()
if (ARM64 OR ARM OR X86 OR X64 OR X86_64)
if((ARM64 OR ARM) AND MSVC)
if(WINDOWS_STORE OR ((ARM64 OR ARM) AND MSVC))
# msvc compiler report syntax error with cpuinfo arm source files
# and cpuinfo does not have code for getting arm uarch info under windows
else()
@ -242,4 +242,3 @@ if (ARM64 OR ARM OR X86 OR X64 OR X86_64)
list(APPEND onnxruntime_EXTERNAL_LIBRARIES cpuinfo clog)
endif()
endif()

Просмотреть файл

@ -21,3 +21,16 @@ set_target_properties(onnxruntime_flatbuffers PROPERTIES FOLDER "ONNXRuntime")
if (FLATBUFFERS_BUILD_FLATC)
add_dependencies(onnxruntime_flatbuffers flatc)
endif()
if (WINDOWS_STORE)
function(target_force_include target scope file)
if (MSVC)
target_compile_options(${target} ${scope} "/FI${file}")
else()
target_compile_options(${target} ${scope} -include "${file}")
endif()
endfunction()
target_force_include(flatbuffers PRIVATE uwp_stubs.h)
target_force_include(flatc PRIVATE uwp_stubs.h)
endif()

Просмотреть файл

@ -12,7 +12,7 @@ function(target_precompiled_header target_name header_name)
# Generate the source file that builds the precompiled header. The generated file will have
# the same base name as the input header name, but has the .cpp extension.
set(pch_source_path ${CMAKE_CURRENT_BINARY_DIR}/${header_base_name}.cpp)
set(pch_source_path ${CMAKE_CURRENT_BINARY_DIR}/${target_name}_${header_base_name}.cpp)
set(pch_source_content "// THIS FILE IS GENERATED BY CMAKE\n#include \"${pch_header_path}\"")
file(WRITE ${pch_source_path} ${pch_source_content})
set_source_files_properties(${pch_source_path} PROPERTIES COMPILE_FLAGS "/Yc${pch_header_path}")

11
cmake/uwp_stubs.h Normal file
Просмотреть файл

@ -0,0 +1,11 @@
#pragma once
// Part of the standard C runtime and the STL are missing when targeting UWP, and some applications that rely on standard,
// cross-platform headers fail to build.
// Here we provide stubs for functions required by some onnxruntime dependencies.
#ifdef __cplusplus
// Extending the std namespace is undefined behavior
// NOLINTNEXTLINE
namespace std {
inline char *getenv(const char*) { return nullptr; }
}
#endif

Просмотреть файл

@ -175,7 +175,7 @@ target_compile_definitions(winml_lib_telemetry PRIVATE _SCL_SECURE_NO_WARNINGS)
target_compile_definitions(winml_lib_telemetry PRIVATE BINARY_NAME=\"${BINARY_NAME}\")
# Specify the usage of a precompiled header
target_precompiled_header(winml_lib_telemetry pch.h)
target_precompiled_header(winml_lib_telemetry lib/Telemetry/pch.h)
# Includes
target_include_directories(winml_lib_telemetry PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # windows machine learning generated component headers
@ -186,6 +186,7 @@ target_include_directories(winml_lib_telemetry PRIVATE ${CMAKE_SOURCE_DIR}/commo
target_include_directories(winml_lib_telemetry PRIVATE ${winml_lib_telemetry_dir})
target_include_directories(winml_lib_telemetry PRIVATE ${winml_lib_common_dir}/inc)
target_include_directories(winml_lib_telemetry PRIVATE ${ONNXRUNTIME_INCLUDE_DIR}/core/platform/windows)
target_include_directories(winml_lib_telemetry PRIVATE ${REPO_ROOT}/winml)
# Properties
set_target_properties(winml_lib_telemetry
@ -247,7 +248,7 @@ if (onnxruntime_WINML_NAMESPACE_OVERRIDE STREQUAL "Windows")
endif()
# Specify the usage of a precompiled header
target_precompiled_header(winml_lib_ort pch.h)
target_precompiled_header(winml_lib_ort lib/Api.Ort/pch.h)
# Includes
target_include_directories(winml_lib_ort PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/winml_api) # windows machine learning generated component headers
@ -323,9 +324,10 @@ target_include_directories(winml_adapter PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INC
add_dependencies(winml_adapter ${onnxruntime_EXTERNAL_DEPENDENCIES})
# Specify the usage of a precompiled header
target_precompiled_header(winml_adapter pch.h)
target_precompiled_header(winml_adapter adapter/pch.h)
# Includes
target_include_directories(winml_adapter PRIVATE ${REPO_ROOT}/winml)
target_include_directories(winml_adapter PRIVATE ${winml_adapter_dir})
target_include_directories(winml_adapter PRIVATE ${winml_lib_common_dir}/inc)
@ -388,7 +390,7 @@ target_compile_definitions(winml_lib_image PRIVATE PLATFORM_WINDOWS)
target_compile_definitions(winml_lib_image PRIVATE _SCL_SECURE_NO_WARNINGS) # remove warnings about unchecked iterators
# Specify the usage of a precompiled header
target_precompiled_header(winml_lib_image pch.h)
target_precompiled_header(winml_lib_image lib/Api.Image/pch.h)
# Includes
target_include_directories(winml_lib_image PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # windows machine learning generated component headers
@ -408,6 +410,7 @@ target_include_directories(winml_lib_image PRIVATE ${ONNXRUNTIME_INCLUDE_DIR}/co
target_include_directories(winml_lib_image PRIVATE ${REPO_ROOT}/cmake/external/flatbuffers/include)
target_include_directories(winml_lib_image PRIVATE ${REPO_ROOT}/cmake/external/optional-lite/include)
target_include_directories(winml_lib_image PRIVATE ${REPO_ROOT}/cmake/external/mp11/include)
target_include_directories(winml_lib_image PRIVATE ${REPO_ROOT}/winml)
# Properties
set_target_properties(winml_lib_image
@ -492,7 +495,7 @@ target_compile_definitions(winml_lib_api PRIVATE PLATFORM_WINDOWS)
target_compile_definitions(winml_lib_api PRIVATE _SCL_SECURE_NO_WARNINGS) # remove warnings about unchecked iterators
# Specify the usage of a precompiled header
target_precompiled_header(winml_lib_api pch.h)
target_precompiled_header(winml_lib_api lib/Api/pch/pch.h)
# Includes
target_include_directories(winml_lib_api PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/winml_api) # windows machine learning generated component headers
@ -524,6 +527,7 @@ target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/Saf
target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/flatbuffers/include)
target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/optional-lite/include)
target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/cmake/external/mp11/include)
target_include_directories(winml_lib_api PRIVATE ${REPO_ROOT}/winml)
# Properties
set_target_properties(winml_lib_api
@ -581,7 +585,7 @@ target_compile_definitions(winml_lib_api_experimental PRIVATE PLATFORM_WINDOWS)
target_compile_definitions(winml_lib_api_experimental PRIVATE _SCL_SECURE_NO_WARNINGS) # remove warnings about unchecked iterators
# Specify the usage of a precompiled header
target_precompiled_header(winml_lib_api_experimental pch.h)
target_precompiled_header(winml_lib_api_experimental lib/Api.Experimental/pch/pch.h)
# Includes
target_include_directories(winml_lib_api_experimental PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/winml_api) # windows machine learning generated component headers
@ -615,6 +619,7 @@ target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake
target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake/external/flatbuffers/include)
target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake/external/optional-lite/include)
target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/cmake/external/mp11/include)
target_include_directories(winml_lib_api_experimental PRIVATE ${REPO_ROOT}/winml)
# Properties
set_target_properties(winml_lib_api_experimental
@ -685,7 +690,8 @@ target_include_directories(winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/
target_include_directories(winml_lib_common PRIVATE ${winml_lib_api_dir})
target_include_directories(winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_include_directories(winml_lib_common PRIVATE ${winml_lib_common_dir}/inc)
target_precompiled_header(winml_lib_common inc/pch.h)
target_include_directories(winml_lib_common PRIVATE ${REPO_ROOT}/winml)
target_precompiled_header(winml_lib_common lib/Common/inc/pch.h)
if (onnxruntime_USE_DML)
target_add_dml(winml_lib_common)
@ -702,7 +708,7 @@ set_source_files_properties(
TRUE)
# Add library
onnxruntime_add_shared_library(winml_dll
onnxruntime_add_shared_library(winml_dll
${CMAKE_CURRENT_BINARY_DIR}/winml_api/comp_generated/module.g.excl.cpp
${winml_dll_dir}/winml.def
${winml_dll_dir}/winml.rc
@ -733,7 +739,7 @@ if (onnxruntime_WINML_NAMESPACE_OVERRIDE STREQUAL "Windows")
endif()
# Specify the usage of a precompiled header
target_precompiled_header(winml_dll pch.h)
target_precompiled_header(winml_dll dll/pch.h)
# Includes
target_include_directories(winml_dll PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/winml_api) # windows machine learning generated component headers
@ -770,6 +776,7 @@ target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/SafeInt
target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/flatbuffers/include)
target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/optional-lite/include)
target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/mp11/include)
target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/winml)
# Properties
set_target_properties(winml_dll

Просмотреть файл

@ -156,7 +156,7 @@ function(target_cppwinrt
${midl_options}
${renamed_idl_fullpath_back_slash}
COMMAND
${cppwinrt_exe} -in ${winmd_filename} -comp ${output_dir_back_slash} -ref ${sdk_metadata_directory} ${add_ref} -out ${generated_dir_back_slash} -verbose
${cppwinrt_exe} -in ${winmd_filename} -comp ${output_dir_back_slash} -pch dll/pch.h -ref ${sdk_metadata_directory} ${add_ref} -out ${generated_dir_back_slash} -verbose
COMMAND
# copy the generated component files into a temporary directory where headers exclusions will be applied
xcopy ${output_dir_back_slash} ${temp_dir_back_slash}\\ /Y /D

Просмотреть файл

@ -191,7 +191,7 @@ set_winml_target_properties(winml_google_test_lib)
set_winml_target_properties(winml_test_common)
get_winml_test_api_src(${WINML_TEST_SRC_DIR} winml_test_api_src)
if (NOT ${winml_is_inbox})
if (NOT WINDOWS_STORE AND NOT ${winml_is_inbox})
get_winml_test_api_redist_only_src(${WINML_TEST_SRC_DIR} winml_test_api_redist_only_src)
endif()

Просмотреть файл

@ -22,9 +22,13 @@
#include "core/common/cpuid_info.h"
#if defined(CPUIDINFO_ARCH_X86) || defined(CPUIDINFO_ARCH_ARM)
#if defined(_MSC_VER) && defined(CPUIDINFO_ARCH_ARM)
// pytorch cpu info does not work for Windows ARM
#if _WIN32
#define NO_WINDOWS_DESKTOP !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#endif
#if NO_WINDOWS_DESKTOP || (defined(_MSC_VER) && defined(CPUIDINFO_ARCH_ARM))
// pytorch cpu info does not work for Windows UWP or ARM
// UWP: Some APIs are not available
// ARM:
// 1. msvc report syntax error in file src/arm/api.h
// 2. features reporting micro-arch in Windows is missing
#else

Просмотреть файл

@ -425,6 +425,7 @@ TEST(ThreadPoolTest, TestStagedMultiLoopSections_4Thread_100Loop) {
TestStagedMultiLoopSections("TestStagedMultiLoopSections_4Thread_100Loop", 4, 100);
}
#ifdef _WIN32
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
#pragma warning(push)
#pragma warning(disable : 6387)
TEST(ThreadPoolTest, TestStackSize) {
@ -455,5 +456,6 @@ TEST(ThreadPoolTest, TestStackSize) {
}
#pragma warning(pop)
#endif
#endif
} // namespace onnxruntime

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "adapter/pch.h"
#ifdef USE_DML

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "adapter/pch.h"
#include "winml_adapter_c_api.h"
#include "winml_adapter_apis.h"
@ -105,4 +105,4 @@ const WinmlAdapterApi* ORT_API_CALL OrtGetWinMLAdapter(_In_ const OrtApi* ort_ap
}
return nullptr;
}
}

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License.
#pragma once
#include "pch.h"
#include "adapter/pch.h"
#include "winml_adapter_c_api.h"
#include "core/session/ort_apis.h"

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License.
#pragma once
#include "pch.h"
#include "adapter/pch.h"
#include "winml_adapter_c_api.h"
#include "core/session/ort_apis.h"
@ -82,4 +82,4 @@ ORT_API_STATUS_IMPL(winmla::OverrideSchema) {
#endif USE_DML.
return nullptr;
API_IMPL_END
}
}

Просмотреть файл

@ -3,7 +3,7 @@
#pragma once
#include "pch.h"
#include "adapter/pch.h"
#include "winml_adapter_c_api.h"
#include "core/session/ort_apis.h"
@ -88,4 +88,4 @@ ORT_API_STATUS_IMPL(winmla::GetValueMemoryInfo, const OrtValue* value, OrtMemory
}
return nullptr;
API_IMPL_END
}
}

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License.
#pragma once
#include "pch.h"
#include "adapter/pch.h"
#include "winml_adapter_model.h"

Просмотреть файл

@ -2,7 +2,7 @@
// Licensed under the MIT License.
#pragma once
#include "pch.h"
#include "adapter/pch.h"
#include "winml_adapter_c_api.h"
#include "core/session/ort_apis.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "dll/pch.h"
#include <windows.h>
#include <Hstring.h>
#include "LearningModelDevice.h"
@ -137,5 +137,9 @@ STDAPI DllGetActivationFactory(HSTRING classId, void** factory) {
// LoadLibraryW isn't support on Windows 8.1. This is a workaround so that CppWinRT calls this function for loading libraries
void* __stdcall WINRT_IMPL_LoadLibraryW(wchar_t const* name) noexcept {
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
return LoadLibraryExW(name, nullptr, 0);
}
#else
return LoadPackagedLibrary(name, 0);
#endif
}

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Experimental/pch/pch.h"
#include "LearningModelBuilder.h"
#include "LearningModel.h"
#include "TensorFeatureDescriptor.h"

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Experimental/pch/pch.h"
#include "LearningModelInputs.h"
#include "LearningModelOperator.h"
#include "LearningModelSession.h"

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Experimental/pch/pch.h"
#include "LearningModelOperator.h"
namespace WINML_EXPERIMENTALP {

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Experimental/pch/pch.h"
#include "LearningModelOperatorSet.h"
#include "LearningModelOperator.h"

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Experimental/pch/pch.h"
#include "LearningModelOutputs.h"
#include "LearningModelBuilder.h"
#include "TensorFeatureDescriptor.h"

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Experimental/pch/pch.h"
#include "LearningModelSessionOptionsExperimental.h"
#include "LearningModelSessionExperimental.h"

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Experimental/pch/pch.h"
#include "LearningModelSessionOptionsExperimental.h"
#include "winrt/Windows.Foundation.Collections.h"
#include "LearningModelSession.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Image/pch.h"
#include "inc/ConverterResourceStore.h"
#include <winrt\windows.media.h>

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Image/pch.h"
#include "inc/D3DDeviceCache.h"
#include <directxmath.h>
#include <d3d11on12.h>

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Image/pch.h"
#if USE_DML
#include <DirectML.h>

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Image/pch.h"
#include "inc/DisjointBufferHelpers.h"
namespace _winml {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Image/pch.h"
#include "inc/ImageConversionHelpers.h"
#include <winrt/Windows.Graphics.DirectX.Direct3D11.h>

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Image/pch.h"
#include "inc/ImageConverter.h"
#include "inc/ImageConversionHelpers.h"
#include "inc/D3DDeviceCache.h"

Просмотреть файл

@ -1,4 +1,4 @@
#include "pch.h"
#include "lib/Api.Image/pch.h"
#include "inc/NominalRangeConverter.h"
namespace _winml {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Image/pch.h"
#include <winmeta.h> // winmeta needed for TraceLoggingKeyword
#include <TraceLoggingProvider.h>

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Image/pch.h"
#include <winmeta.h> // winmeta needed for TraceLoggingKeyword
#include <TraceLoggingProvider.h>

Просмотреть файл

@ -11,7 +11,13 @@
#define ENABLE_DXCORE 1
#endif
#ifdef ENABLE_DXCORE
// dxcore is delay loaded, so there is a runtime check for its existence and it's always okay to reference,
// even in unsupported versions of Windows
#pragma push_macro("_WIN32_WINNT")
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <dxcore.h>
#pragma pop_macro("_WIN32_WINNT")
#endif
namespace _winml {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Ort/pch.h"
#include "OnnxruntimeCpuSessionBuilder.h"
#include "OnnxruntimeEngine.h"
#include "OnnxruntimeErrors.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Ort/pch.h"
#include <evntrace.h>

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Ort/pch.h"
#ifdef USE_DML

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Ort/pch.h"
#include "OnnxruntimeEngine.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Ort/pch.h"
#include "OnnxruntimeEngine.h"
#include "OnnxruntimeEngineBuilder.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Ort/pch.h"
#include "OnnxruntimeEnvironment.h"
#include "OnnxruntimeErrors.h"
#include "core/platform/windows/TraceLoggingConfig.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api.Ort/pch.h"
#include "OnnxruntimeModel.h"
#include "core/platform/windows/TraceLoggingConfig.h"
#include <evntrace.h>

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "ImageFeatureDescriptor.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "ImageFeatureValue.h"
#include "LearningModelBinding.h"
#include "LearningModelDevice.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "LearningModel.h"
@ -21,13 +21,23 @@ LearningModel::LearningModel(
_winmlt::TelemetryEvent loadModel_event(_winmlt::EventCategory::kModelLoad);
WINML_THROW_IF_FAILED(CreateOnnxruntimeEngineFactory(engine_factory_.put()));
auto file_handle = wil::unique_handle(CreateFileW(path.c_str(),
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_READONLY,
NULL));
wil::unique_handle file_handle{
#if WINVER >= _WIN32_WINNT_WIN8
CreateFile2(path.c_str(),
GENERIC_READ,
0,
OPEN_EXISTING,
NULL)};
#else
CreateFileW(path.c_str(),
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_READONLY,
NULL)};
#endif
WINML_THROW_HR_IF_TRUE_MSG(__HRESULT_FROM_WIN32(GetLastError()),
file_handle.get() == INVALID_HANDLE_VALUE,
@ -53,12 +63,12 @@ LearningModel::LearningModel(
WINML_THROW_HR_IF_TRUE_MSG(__HRESULT_FROM_WIN32(GetLastError()),
file_mapping == nullptr,
"Model load failed!");
auto file_size_in_bytes = GetFileSize(file_handle.get(), NULL);
WINML_THROW_IF_FAILED(engine_factory_->CreateModel(buffer, file_size_in_bytes, model_.put()));
LARGE_INTEGER file_size;
WINML_THROW_HR_IF_FALSE_MSG(__HRESULT_FROM_WIN32(GetLastError()),
GetFileSizeEx(file_handle.get(), &file_size),
"GetFileSizeEx");
WINML_THROW_IF_FAILED(engine_factory_->CreateModel(buffer, static_cast<size_t>(file_size.QuadPart), model_.put()));
WINML_THROW_HR_IF_TRUE_MSG(E_UNEXPECTED, UnmapViewOfFile(buffer) == 0, "Could not unmap model file.");
WINML_THROW_IF_FAILED(model_->GetModelInfo(model_info_.put()));
}
WINML_CATCH_ALL

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "ConverterResourceStore.h"
#include "impl/FeatureCompatibility.h"
#include "FeatureValues.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "LearningModelDevice.h"
#include <D3d11_4.h>

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "LearningModelEvaluationResult.h"
namespace WINMLP {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "LearningModelSession.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "LearningModelSessionOptions.h"
namespace WINMLP {

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "MapFeatureDescriptor.h"

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "impl/NumericData.h"
#include "VectorBackedBuffer.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "SequenceFeatureDescriptor.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "impl/StringData.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "LearningModel.h"

Просмотреть файл

@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Api/pch/pch.h"
#include "VectorBackedBuffer.h"

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "inc/pch.h"
#include "lib/Common/inc/pch.h"
#if USE_DML
#include <DirectML.h>
#endif USE_DML

Просмотреть файл

@ -13,7 +13,13 @@
#define ENABLE_DXCORE 1
#endif
#ifdef ENABLE_DXCORE
// dxcore is delay loaded, so there is a runtime check for its existence and it's okay to reference,
// even in unsupported versions of Windows
#pragma push_macro("_WIN32_WINNT")
#undef _WIN32_WINNT
#define _WIN32_WINNT _WIN32_WINNT_WIN10
#include <dxcore.h>
#pragma pop_macro("_WIN32_WINNT")
#endif
//

Просмотреть файл

@ -3,6 +3,8 @@
#pragma once
#include <winstring.h>
// String Helpers
namespace _winml::Strings {
struct HStringBuilder {

Просмотреть файл

@ -27,7 +27,6 @@
// WIL
#include <wil/cppwinrt.h>
#include <wil/result.h>
#include <wil/wrl.h>
#include <wil/winrt.h>
// Windows pollutes with preprocessor that redefine OPTIONAL.

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Telemetry/pch.h"
WinMLTelemetryHelper telemetry_helper;

Просмотреть файл

@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#include "lib/Telemetry/pch.h"
#include "inc/TelemetryEvent.h"

Просмотреть файл

@ -7,7 +7,7 @@
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "pch.h"
#include "lib/Telemetry/pch.h"
WinMLTelemetryHelper::WinMLTelemetryHelper()
: provider_(winml_trace_logging_provider) {

Просмотреть файл

@ -4,7 +4,6 @@
#include "testPch.h"
#include "AdapterDmlEpTest.h"
#include <wil/result.h>
#include "common.h"
#include "iengine.h"

Просмотреть файл

@ -13,14 +13,14 @@ static void LoadModel(const std::wstring& modelPath,
learningModel = winml::LearningModel::LoadFromFilePath(fullPath);
};
static uint64_t GetAdapterIdQuadPart(winml::LearningModelDevice& device) {
static inline uint64_t GetAdapterIdQuadPart(winml::LearningModelDevice& device) {
LARGE_INTEGER id;
id.LowPart = device.AdapterId().LowPart;
id.HighPart = device.AdapterId().HighPart;
return id.QuadPart;
};
static _LUID GetAdapterIdAsLUID(winml::LearningModelDevice& device) {
static inline _LUID GetAdapterIdAsLUID(winml::LearningModelDevice& device) {
_LUID id;
id.LowPart = device.AdapterId().LowPart;
id.HighPart = device.AdapterId().HighPart;

Просмотреть файл

@ -37,7 +37,11 @@ HRESULT __stdcall WINRT_RoGetActivationFactory(HSTRING classId_hstring, GUID con
if (starts_with(name, winml_dll_prefix))
{
const wchar_t* lib_path = winml_dll_path.c_str();
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
library = LoadLibraryExW(lib_path, nullptr, 0);
#else
library = LoadPackagedLibrary(lib_path, 0);
#endif
}
else
{