mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
Cmake and preprocessor fixes that where uncovered by building on agents without DML available via SDK
This commit is contained in:
parent
56cbd82c71
commit
be48f05c64
3 changed files with 20 additions and 3 deletions
|
|
@ -312,6 +312,9 @@ endif()
|
|||
if (onnxruntime_USE_MKLDNN)
|
||||
target_compile_definitions(onnxruntime_test_utils_for_framework PUBLIC USE_MKLDNN=1)
|
||||
endif()
|
||||
if (onnxruntime_USE_DML)
|
||||
target_link_libraries(onnxruntime_test_utils_for_framework PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/packages/DirectML.0.0.1/build/DirectML.targets)
|
||||
endif()
|
||||
add_dependencies(onnxruntime_test_utils_for_framework ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
||||
target_include_directories(onnxruntime_test_utils_for_framework PUBLIC "${TEST_SRC_DIR}/util/include" PRIVATE ${eigen_INCLUDE_DIRS} ${ONNXRUNTIME_ROOT})
|
||||
# Add the define for conditionally using the framework Environment class in TestEnvironment
|
||||
|
|
@ -327,6 +330,9 @@ endif()
|
|||
if (onnxruntime_USE_MKLDNN)
|
||||
target_compile_definitions(onnxruntime_test_utils PUBLIC USE_MKLDNN=1)
|
||||
endif()
|
||||
if (onnxruntime_USE_DML)
|
||||
target_link_libraries(onnxruntime_test_utils PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/packages/DirectML.0.0.1/build/DirectML.targets)
|
||||
endif()
|
||||
add_dependencies(onnxruntime_test_utils ${onnxruntime_EXTERNAL_DEPENDENCIES})
|
||||
target_include_directories(onnxruntime_test_utils PUBLIC "${TEST_SRC_DIR}/util/include" PRIVATE ${eigen_INCLUDE_DIRS} ${ONNXRUNTIME_ROOT})
|
||||
set_target_properties(onnxruntime_test_utils PROPERTIES FOLDER "ONNXRuntimeTest")
|
||||
|
|
|
|||
|
|
@ -238,6 +238,9 @@ add_dependencies(winml_lib_image winml_api_native_internal)
|
|||
|
||||
# Link libraries
|
||||
target_link_libraries(winml_lib_image PRIVATE wil)
|
||||
if (onnxruntime_USE_DML)
|
||||
target_link_libraries(winml_lib_image PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/packages/DirectML.0.0.1/build/DirectML.targets)
|
||||
endif(onnxruntime_USE_DML)
|
||||
|
||||
|
||||
###########################
|
||||
|
|
@ -337,6 +340,9 @@ add_dependencies(winml_lib_api winml_api_native_internal)
|
|||
|
||||
# Link libraries
|
||||
target_link_libraries(winml_lib_api PRIVATE wil)
|
||||
if (onnxruntime_USE_DML)
|
||||
target_link_libraries(winml_lib_api PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/packages/DirectML.0.0.1/build/DirectML.targets)
|
||||
endif(onnxruntime_USE_DML)
|
||||
|
||||
|
||||
###########################
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@
|
|||
|
||||
#include "pch.h"
|
||||
|
||||
#include "DirectML.h"
|
||||
#if USE_DML
|
||||
#include <DirectML.h>
|
||||
#endif USE_DML
|
||||
#include <d3d11on12.h>
|
||||
#include <wil/winrt.h>
|
||||
#include "inc/DeviceHelpers.h"
|
||||
|
|
@ -139,11 +141,14 @@ bool IsFloat16Supported(const winrt::Windows::AI::MachineLearning::LearningModel
|
|||
}
|
||||
|
||||
bool IsFloat16Supported(ID3D12Device* device) {
|
||||
#ifndef USE_DML
|
||||
WINML_THROW_HR_IF_TRUE_MSG(ERROR_NOT_SUPPORTED, true, "IsFloat16Supported is not implemented for WinML only build.");
|
||||
return false;
|
||||
#else
|
||||
bool isBlocked;
|
||||
if (FAILED(IsFloat16Blocked(*device, &isBlocked)) || isBlocked) {
|
||||
return false;
|
||||
}
|
||||
|
||||
winrt::com_ptr<IDMLDevice> dmlDevice;
|
||||
winrt::check_hresult(DMLCreateDevice(
|
||||
device,
|
||||
|
|
@ -159,8 +164,8 @@ bool IsFloat16Supported(ID3D12Device* device) {
|
|||
&float16Query,
|
||||
sizeof(float16Data),
|
||||
&float16Data));
|
||||
|
||||
return float16Data.IsSupported;
|
||||
#endif USE_DML
|
||||
}
|
||||
|
||||
// uses Structured Exception Handling (SEH) to detect for delay load failures of target API.
|
||||
|
|
|
|||
Loading…
Reference in a new issue