Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 0 additions & 3 deletions cmake/onnxruntime_providers_webgpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
endif()

add_compile_definitions(USE_WEBGPU=1)
if(onnxruntime_BUILD_WEBGPU_EP_STATIC_LIB)
add_compile_definitions(BUILD_WEBGPU_EP_STATIC_LIB=1)
endif()

if (onnxruntime_ENABLE_WEBASSEMBLY_THREADS)
add_definitions(-DENABLE_WEBASSEMBLY_THREADS=1)
Expand Down
10 changes: 6 additions & 4 deletions include/onnxruntime/ep/adapters.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

#pragma once

#include "api.h"
#include "common.h"

// This header is only used when building WebGPU/CUDA EP as a shared library.
// This header is only used when building WebGPU/CUDA EP as a plugin EP library.
//
// This header file is used as a precompiled header so it is always included first.

#define ORT_EP_API_ADAPTER
Comment thread
fs-eire marked this conversation as resolved.
Outdated

#include "api.h"

Check warning on line 12 in include/onnxruntime/ep/adapters.h

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Include the directory when naming header files [build/include_subdir] [4] Raw Output: include/onnxruntime/ep/adapters.h:12: Include the directory when naming header files [build/include_subdir] [4]
#include "common.h"

Check warning on line 13 in include/onnxruntime/ep/adapters.h

View workflow job for this annotation

GitHub Actions / Optional Lint C++

[cpplint] reported by reviewdog 🐶 Include the directory when naming header files [build/include_subdir] [4] Raw Output: include/onnxruntime/ep/adapters.h:13: Include the directory when naming header files [build/include_subdir] [4]

#pragma push_macro("ORT_EP_API_ADAPTER_HEADER_INCLUDED")
#undef ORT_EP_API_ADAPTER_HEADER_INCLUDED
#define ORT_EP_API_ADAPTER_HEADER_INCLUDED
Expand Down
10 changes: 5 additions & 5 deletions onnxruntime/core/dll/delay_load_hook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
// - https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#alternate-search-order-for-unpackaged-apps
//
// The DLL DelayLoad hook is only enabled when the compiler is MSVC and at least one of the following is True:
// - all of the following are defined:
// - USE_WEBGPU
// - BUILD_WEBGPU_EP_STATIC_LIB
// - BUILD_DAWN_SHARED_LIBRARY
// - all of the following are true:
// - USE_WEBGPU is defined
// - ORT_EP_API_ADAPTER is NOT defined (i.e., WebGPU EP is statically linked)
// - BUILD_DAWN_SHARED_LIBRARY is defined
// - USE_DML is defined
//
#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB) && defined(BUILD_DAWN_SHARED_LIBRARY)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER) && defined(BUILD_DAWN_SHARED_LIBRARY)
#define ORT_DELAY_LOAD_WEBGPU_DAWN_DLL 1
#else
#define ORT_DELAY_LOAD_WEBGPU_DAWN_DLL 0
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/providers/get_execution_providers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ constexpr ProviderInfo kProvidersInPriorityOrder[] =
},
{
kWebGpuExecutionProvider,
#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
true,
#else
false,
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/session/ort_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ std::atomic<bool> g_is_shutting_down(false);
using namespace onnxruntime;
using namespace onnxruntime::logging;

#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
namespace onnxruntime {
namespace webgpu {
void CleanupWebGpuContexts();
Expand All @@ -41,7 +41,7 @@ OrtEnv::~OrtEnv() {
UnloadSharedProviders();
#endif

#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
// Explicitly destroy the Environment first, which will properly clean up DataTransferManager
// and call ReleaseImpl on WebGpuDataTransferImpl
value_.reset();
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/session/plugin_ep/ep_factory_webgpu.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
#include "core/session/plugin_ep/ep_factory_webgpu.h"

#include "core/framework/error_code_helper.h"
Expand Down Expand Up @@ -73,4 +73,4 @@ OrtStatus* WebGpuEpFactory::CreateDataTransfer(_Outptr_result_maybenull_ OrtData

} // namespace onnxruntime

#endif // defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#endif // defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
4 changes: 2 additions & 2 deletions onnxruntime/core/session/plugin_ep/ep_factory_webgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#pragma once

#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
#include "core/session/plugin_ep/ep_factory_internal_impl.h"

#include "core/graph/constants.h"
Expand Down Expand Up @@ -34,4 +34,4 @@ class WebGpuEpFactory : public EpFactoryInternalImpl {
};
} // namespace onnxruntime

#endif // defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#endif // defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
4 changes: 2 additions & 2 deletions onnxruntime/core/session/plugin_ep/ep_library_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ std::unique_ptr<EpLibraryInternal> EpLibraryInternal::CreateDmlEp() {
}
#endif

#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
std::unique_ptr<EpLibraryInternal> EpLibraryInternal::CreateWebGpuEp() {
auto webgpu_factory_impl = std::make_unique<WebGpuEpFactory>();
auto internal_factory = std::make_unique<EpFactoryInternal>(std::move(webgpu_factory_impl));
Expand All @@ -38,7 +38,7 @@ std::vector<std::unique_ptr<EpLibraryInternal>> EpLibraryInternal::CreateInterna
// CPU EP
internal_eps.push_back(CreateCpuEp());

#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
internal_eps.push_back(CreateWebGpuEp());
#endif

Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/session/plugin_ep/ep_library_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class EpLibraryInternal : public EpLibrary {
#if defined(USE_DML)
static std::unique_ptr<EpLibraryInternal> CreateDmlEp();
#endif
#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
static std::unique_ptr<EpLibraryInternal> CreateWebGpuEp();
#endif

Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/core/session/provider_registration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ ORT_API_STATUS_IMPL(OrtApis::SessionOptionsAppendExecutionProvider,
break;
}
case EpID::WebGPU: {
#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
options->provider_factories.push_back(WebGpuProviderFactoryCreator::Create(options->value.config_options));
#else
status = create_not_supported_status();
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/test/unittest_util/base_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ void BaseTester::RunWithConfig(size_t* number_of_pre_packed_weights_counter,
kQnnExecutionProvider,
kSnpeExecutionProvider,
kXnnpackExecutionProvider,
#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
kWebGpuExecutionProvider,
#endif
};
Expand Down Expand Up @@ -750,7 +750,7 @@ void BaseTester::RunWithConfig(size_t* number_of_pre_packed_weights_counter,
execution_provider = DefaultXnnpackExecutionProvider();
else if (provider_type == onnxruntime::kDmlExecutionProvider)
execution_provider = DefaultDmlExecutionProvider();
#if !defined(USE_WEBGPU) || defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if !defined(USE_WEBGPU) || !defined(ORT_EP_API_ADAPTER)
else if (provider_type == onnxruntime::kWebGpuExecutionProvider)
execution_provider = DefaultWebGpuExecutionProvider();
#endif
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/test/util/default_providers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ std::unique_ptr<IExecutionProvider> DefaultXnnpackExecutionProvider() {
}

std::unique_ptr<IExecutionProvider> DefaultWebGpuExecutionProvider(bool is_nhwc) {
#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
ConfigOptions config_options{};
// Disable storage buffer cache
ORT_ENFORCE(config_options.AddConfigEntry(webgpu::options::kStorageBufferCacheMode,
Expand All @@ -302,7 +302,7 @@ std::unique_ptr<IExecutionProvider> DefaultWebGpuExecutionProvider(bool is_nhwc)
}

std::unique_ptr<IExecutionProvider> WebGpuExecutionProviderWithOptions(const ConfigOptions& config_options) {
#if defined(USE_WEBGPU) && defined(BUILD_WEBGPU_EP_STATIC_LIB)
#if defined(USE_WEBGPU) && !defined(ORT_EP_API_ADAPTER)
return WebGpuProviderFactoryCreator::Create(config_options)->CreateProvider();
#else
ORT_UNUSED_PARAMETER(config_options);
Expand Down
Loading