diff --git a/cmake/onnx/CMakeLists.txt b/cmake/onnx/CMakeLists.txt index 1048c90bd2c5c..d14f51e455b41 100644 --- a/cmake/onnx/CMakeLists.txt +++ b/cmake/onnx/CMakeLists.txt @@ -6,7 +6,7 @@ target_include_directories(onnx_proto PUBLIC $) onnxruntime_protobuf_generate(APPEND_PATH IMPORT_DIRS ${ONNXRUNTIME_ROOT}/core/protobuf TARGET onnx_proto) if (WIN32) - target_compile_options(onnx_proto PRIVATE "/wd4146" "/wd4125" "/wd4456" "/wd4267") + target_compile_options(onnx_proto PRIVATE "/wd4146" "/wd4125" "/wd4456" "/wd4267" "/wd4309") else() if(HAS_UNUSED_VARIABLE) target_compile_options(onnx_proto PRIVATE "-Wno-unused-variable") @@ -51,6 +51,7 @@ if (WIN32) /wd4100 # 'param' : unreferenced formal parameter /wd4244 # 'argument' conversion from 'google::protobuf::int64' to 'int', possible loss of data /EHsc # exception handling - C++ may throw, extern "C" will not + /wd4996 # 'argument' Using double parameter version instead of single parameter version of SetTotalBytesLimit(). The second parameter is ignored. ) set(onnx_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 diff --git a/cmake/winml.cmake b/cmake/winml.cmake index 2958a16681793..088ef107a8830 100644 --- a/cmake/winml.cmake +++ b/cmake/winml.cmake @@ -166,7 +166,6 @@ target_include_directories(winml_adapter PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/win target_include_directories(winml_adapter PRIVATE ${winml_lib_api_dir}) # needed for generated headers target_include_directories(winml_adapter PRIVATE ${winml_lib_dir}) target_include_directories(winml_adapter PRIVATE ${winml_adapter_dir}) -target_include_directories(winml_adapter PRIVATE ${winml_lib_common_dir}/inc) set_target_properties(winml_adapter PROPERTIES @@ -386,11 +385,17 @@ target_compile_definitions(winml_lib_common PRIVATE PLATFORM_WINDOWS _SCL_SECURE_NO_WARNINGS) add_dependencies(winml_lib_common winml_sdk_cppwinrt) +add_dependencies(winml_lib_common winml_api) +add_dependencies(winml_lib_common winml_api_native) +add_dependencies(winml_lib_common winml_api_native_internal) target_include_directories(winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/winml_api) # windows machine learning generated component headers target_include_directories(winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/winml_api/comp_generated) # windows machine learning generated component headers +target_include_directories(winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/winml/sdk/cppwinrt/include) # sdk cppwinrt headers 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) ########################### # Add winml_dll diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorPooling.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorPooling.cpp index 7f27291ede562..b64ae7dc751ae 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorPooling.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorPooling.cpp @@ -134,7 +134,7 @@ class DmlOperatorPoolingTemplate : public DmlOperatorPooling } }; -void QueryMaxPool(IMLOperatorSupportQueryContextPrivate* context, bool *isSupported) +void CALLBACK QueryMaxPool(IMLOperatorSupportQueryContextPrivate* context, bool *isSupported) { *isSupported = false; diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorSlice.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorSlice.cpp index e167a89f0606e..0e9d0feb5a815 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorSlice.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorSlice.cpp @@ -71,7 +71,7 @@ class DmlOperatorSliceTemplate : public DmlOperatorSlice } }; -void QuerySlice(IMLOperatorSupportQueryContextPrivate* context, bool *isSupported) +void CALLBACK QuerySlice(IMLOperatorSupportQueryContextPrivate* context, bool *isSupported) { *isSupported = (context->GetInputCount() <= 4); } diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/OperatorRegistration.h b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/OperatorRegistration.h index 186608d78b586..45923d528dc05 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/OperatorRegistration.h +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/OperatorRegistration.h @@ -8,8 +8,8 @@ interface IMLOperatorKernel; class MLOperatorKernelCreationContext; // Forward declares an external creation function. -#define DML_OP_EXTERN_CREATION_FUNCTION(operatorName) extern void Create##operatorName(IMLOperatorKernelCreationContext* kernelInfo, IMLOperatorKernel** opKernel) -#define DML_OP_EXTERN_QUERY_FUNCTION(operatorName) extern void Query##operatorName(IMLOperatorSupportQueryContextPrivate* context, bool *isSupported); +#define DML_OP_EXTERN_CREATION_FUNCTION(operatorName) extern void CALLBACK Create##operatorName(IMLOperatorKernelCreationContext* kernelInfo, IMLOperatorKernel** opKernel) +#define DML_OP_EXTERN_QUERY_FUNCTION(operatorName) extern void CALLBACK Query##operatorName(IMLOperatorSupportQueryContextPrivate* context, bool* isSupported); // Declares a callback creation function of the given operator class. // This does not register it, just declares it for usage by registration later. @@ -20,7 +20,7 @@ class MLOperatorKernelCreationContext; // commas in them break the macro, and so they are stuffed into the VA_ARGS. // #define DML_OP_DEFINE_CREATION_FUNCTION(operatorName, ...)\ -extern void Create##operatorName(IMLOperatorKernelCreationContext* kernelInfo, IMLOperatorKernel** opKernel)\ +extern void CALLBACK Create##operatorName(IMLOperatorKernelCreationContext* kernelInfo, IMLOperatorKernel** opKernel)\ {\ using T = __VA_ARGS__; \ THROW_IF_FAILED(MLOperatorKernel::CreateInstance(*kernelInfo, /*out*/ opKernel));\ diff --git a/onnxruntime/core/providers/dml/OperatorAuthorHelper/MLOperatorAuthorHelper.h b/onnxruntime/core/providers/dml/OperatorAuthorHelper/MLOperatorAuthorHelper.h index b15955e0e533d..7fee23b8d0004 100644 --- a/onnxruntime/core/providers/dml/OperatorAuthorHelper/MLOperatorAuthorHelper.h +++ b/onnxruntime/core/providers/dml/OperatorAuthorHelper/MLOperatorAuthorHelper.h @@ -734,7 +734,7 @@ class MLOperatorKernel : public Microsoft::WRL::RuntimeClass< using MLOperatorTypeInferenceFunction = void (CALLBACK*)(IMLOperatorTypeInferenceContext*); using MLOperatorShapeInferenceFunction = void (CALLBACK*)(IMLOperatorShapeInferenceContext*); -using MLOperatorKernelCreateFn = void(*)(IMLOperatorKernelCreationContext*, IMLOperatorKernel**); +using MLOperatorKernelCreateFn = void(CALLBACK*)(IMLOperatorKernelCreationContext*, IMLOperatorKernel**); using MLOperatorSupportQueryFunction = void (CALLBACK*)(IMLOperatorSupportQueryContextPrivate*, bool*); class MLOperatorShapeInferrer : public Microsoft::WRL::RuntimeClass< diff --git a/winml/lib/Common/CommonDeviceHelpers.cpp b/winml/lib/Common/CommonDeviceHelpers.cpp index 292d665ffdf1b..e4e0fd63eb7f3 100644 --- a/winml/lib/Common/CommonDeviceHelpers.cpp +++ b/winml/lib/Common/CommonDeviceHelpers.cpp @@ -3,7 +3,7 @@ // #include "dx.h" // #include - +#include "inc/pch.h" #if USE_DML #include #endif USE_DML diff --git a/winml/lib/Common/inc/CommonDeviceHelpers.h b/winml/lib/Common/inc/CommonDeviceHelpers.h index 38f1aa1e8a13c..14ffe2aeaa035 100644 --- a/winml/lib/Common/inc/CommonDeviceHelpers.h +++ b/winml/lib/Common/inc/CommonDeviceHelpers.h @@ -3,7 +3,6 @@ #pragma once -#include "winrt_headers.h" #include #include #include diff --git a/winml/lib/Common/inc/pch.h b/winml/lib/Common/inc/pch.h new file mode 100644 index 0000000000000..5d070d0c86c3f --- /dev/null +++ b/winml/lib/Common/inc/pch.h @@ -0,0 +1 @@ +#include "winrt_headers.h" \ No newline at end of file diff --git a/winml/test/scenario/cppwinrt/CustomOps.cpp b/winml/test/scenario/cppwinrt/CustomOps.cpp index eb47843b95de6..f1071d52ccb8b 100644 --- a/winml/test/scenario/cppwinrt/CustomOps.cpp +++ b/winml/test/scenario/cppwinrt/CustomOps.cpp @@ -288,13 +288,13 @@ class FooKernel }; template -void CreateABIFooKernel(IMLOperatorKernelCreationContext* kernelInfo, IMLOperatorKernel** opKernel) +void CALLBACK CreateABIFooKernel(IMLOperatorKernelCreationContext* kernelInfo, IMLOperatorKernel** opKernel) { HRESULT hr = MLOperatorKernel>::CreateInstance(*kernelInfo, opKernel); THROW_IF_FAILED(hr); } -void CreateTruncatedABIFooKernel(IMLOperatorKernelCreationContext* kernelInfo, IMLOperatorKernel** opKernel) +void CALLBACK CreateTruncatedABIFooKernel(IMLOperatorKernelCreationContext* kernelInfo, IMLOperatorKernel** opKernel) { HRESULT hr = MLOperatorKernel>::CreateInstance(*kernelInfo, opKernel); THROW_IF_FAILED(hr);