Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix webgpu delay load test #23157

Merged
merged 3 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ option(onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS "Dump debug information about node
cmake_dependent_option(onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS_ENABLE_DUMP_TO_SQLDB "Build dump debug information about node inputs and outputs with support for sql database." OFF "onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS" OFF)

# When loading a delay loaded DLL, Windows searches the main EXE's folder first.
# In a Python process, it searches where python.exe lives, but it doesn't search the python package's installation folder. Therefore we cannot enable this flag when Python is enabled.
cmake_dependent_option(onnxruntime_ENABLE_DELAY_LOADING_WIN_DLLS "Delay load some of the dependent DLls that are part of the OS" ON "WIN32;NOT GDK_PLATFORM;NOT onnxruntime_ENABLE_PYTHON" OFF)
cmake_dependent_option(onnxruntime_ENABLE_DELAY_LOADING_WIN_DLLS "Delay load some of the dependent DLls that are part of the OS" ON "WIN32;NOT GDK_PLATFORM" OFF)
option(onnxruntime_USE_DML "Build with DirectML support" OFF)
option(onnxruntime_USE_MIGRAPHX "Build with AMDMIGraphX support" OFF)
option(onnxruntime_USE_WINML "Build with WinML support" OFF)
Expand Down
14 changes: 11 additions & 3 deletions onnxruntime/core/dll/delay_load_hook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@
// - both USE_WEBGPU and BUILD_DAWN_MONOLITHIC_LIBRARY are defined
// - USE_DML is defined
//
#define ORT_DELAY_LOAD_WEBGPU_DAWN_DLL (defined(USE_WEBGPU) && defined(BUILD_DAWN_MONOLITHIC_LIBRARY))
#define ORT_DELAY_LOAD_DIRECTML_DLL defined(USE_DML)
#if defined(USE_WEBGPU) && defined(BUILD_DAWN_MONOLITHIC_LIBRARY)
#define ORT_DELAY_LOAD_WEBGPU_DAWN_DLL 1
#else
#define ORT_DELAY_LOAD_WEBGPU_DAWN_DLL 0
#endif
#if defined(USE_DML)
#define ORT_DELAY_LOAD_DIRECTML_DLL 1
#else
#define ORT_DELAY_LOAD_DIRECTML_DLL 0
#endif
#if defined(_MSC_VER) && (ORT_DELAY_LOAD_WEBGPU_DAWN_DLL || ORT_DELAY_LOAD_DIRECTML_DLL)

#include <Windows.h>
Expand Down Expand Up @@ -59,7 +67,7 @@ FARPROC WINAPI delay_load_hook(unsigned dliNotify, PDelayLoadInfo pdli) {
// Try to load the DLL from the same directory as onnxruntime.dll

// First, get the path to onnxruntime.dll
auto path = Env::Default().GetRuntimePath();
auto path = onnxruntime::Env::Default().GetRuntimePath();
if (path.empty()) {
// Failed to get the path to onnxruntime.dll. In this case, we will just return NULL and let the system
// search for the DLL in the default search order.
Expand Down
1 change: 1 addition & 0 deletions onnxruntime/test/webgpu/delay_load/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ int test_main() {
HMODULE hModule = LoadLibraryA("dlls\\onnxruntime.dll");
if (hModule == NULL) {
std::cout << "Failed to load dlls\\onnxruntime.dll" << std::endl;
std::cout << "Error code: " << GetLastError() << std::endl;
return 1;
}

Expand Down
Loading