Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
dff9cc4
Add WebGPU EP extraction plans
edgchen1 Aug 17, 2026
a795ec0
Clarify EP conformance runner architecture
edgchen1 Aug 17, 2026
e26dc64
Refine WebGPU extraction lifecycle plans
edgchen1 Aug 17, 2026
6b7d919
Clarify test ownership and align workstream doc structure
edgchen1 Aug 20, 2026
0b96cbf
Address plan review: critical path, work package structure, terminology
edgchen1 Aug 21, 2026
d20f696
Address remaining plan review findings
edgchen1 Aug 21, 2026
e8a42f5
Refine dependency scope and pipeline dispositions in provider isolati…
edgchen1 Aug 22, 2026
800ad88
Resolve internal contradictions found in PR review
edgchen1 Aug 24, 2026
2754674
Support registering statically linked plugin EPs, and build WebGPU EP…
edgchen1 Aug 25, 2026
32775c3
Add CI jobs for the WebGPU static plugin EP build
edgchen1 Aug 26, 2026
49855f6
Fix GCC maybe-uninitialized errors in the EP adapter attribute accessors
edgchen1 Aug 26, 2026
d47f00a
Update dynamic plugin EP test config parsing tests
edgchen1 Aug 26, 2026
1980e90
Record CI coverage in the static plugin EP registration design doc
edgchen1 Aug 26, 2026
994e00b
Suppress GCC maybe-uninitialized on the WebGPU EP adapter build
edgchen1 Aug 26, 2026
754e025
Add a work log for the static plugin EP branch
edgchen1 Aug 26, 2026
a362107
Merge remote-tracking branch 'origin/main' into edgchen1/webgpu_stati…
edgchen1 Aug 26, 2026
35e6f65
Record real-GPU validation results in the static plugin EP work log
edgchen1 Aug 26, 2026
a110948
Record GPU validation and the plugin-path test coverage gap in the de…
edgchen1 Aug 26, 2026
8d87c11
Avoid GCC 14 -Warray-bounds false positive in EmitGateActivationExpr
edgchen1 Aug 26, 2026
ef68884
Record the complete GCC 14 warning inventory and the local reproducti…
edgchen1 Aug 26, 2026
153df4e
Update the work log with the fix verification, push state, and dispat…
edgchen1 Aug 27, 2026
ff3580c
Record the Emscripten/ORT Web build validation for the static plugin EP
edgchen1 Aug 27, 2026
d83e028
Record the ORT Web migration prerequisites in the static plugin EP de…
edgchen1 Aug 27, 2026
7db781f
Reject a minimal build combined with the WebGPU static plugin EP
edgchen1 Aug 27, 2026
014b8de
Record ORT Web plugin-EP prototype results in design doc
edgchen1 Aug 28, 2026
018b24a
Add Emscripten device discovery reporting a GPU when navigator.gpu ex…
edgchen1 Aug 28, 2026
93b8f14
Don't use exceptions for control flow in EP API OpKernelInfo adapter
edgchen1 Aug 28, 2026
e856885
Record WebGPU static_plugin vs static_lib perf comparison in design doc
edgchen1 Aug 28, 2026
6abb02d
Select WebGPU as a plugin EP from ORT Web
edgchen1 Aug 29, 2026
b1ce378
Merge branch 'main' of https://github.com/microsoft/onnxruntime into …
edgchen1 Aug 29, 2026
6a3e4bd
Note upstream allow_software_adapter fallback in Emscripten device di…
edgchen1 Aug 29, 2026
b876d29
Defer zero-initialize submission in the WebGPU plugin EP shared alloc…
edgchen1 Sep 1, 2026
2831d7d
Update measured size and perf comparison with post-merge interleaved …
edgchen1 Sep 1, 2026
afd96be
Record why the shared allocator defect was missed in the pre-merge me…
edgchen1 Sep 1, 2026
a75b4c1
docs: add WebGPU static plugin EP design
edgchen1 Sep 2, 2026
fdf2f53
docs: tighten WebGPU EP extraction plan docs
edgchen1 Sep 2, 2026
0209424
docs: fix inaccurate claims in WebGPU EP extraction overview
edgchen1 Sep 2, 2026
18a2b83
minor updates
edgchen1 Sep 2, 2026
551433f
docs: address PR feedback on conformance results and CI relocation
edgchen1 Sep 2, 2026
ec4b772
Record four-side web benchmark: b876d290cd has no effect on the wasm …
edgchen1 Sep 3, 2026
1dd5a55
Revert "Defer zero-initialize submission in the WebGPU plugin EP shar…
edgchen1 Sep 3, 2026
de610ec
Record the disposition of b876d290cd: reverted and verified
edgchen1 Sep 3, 2026
ea79e2b
Remove the deferred-submission detour from the static plugin EP desig…
edgchen1 Sep 3, 2026
c41055b
Merge edgchen1/webgpu_ep_extraction_plan: authoritative WebGPU EP ext…
edgchen1 Sep 3, 2026
2861a5f
Record the sync convention for the higher-level plan docs
edgchen1 Sep 3, 2026
e75881f
Fix string-array attribute leak in the EP API OpKernelInfo adapter
edgchen1 Sep 3, 2026
7e9fcdc
Collapse the plugin EP build macros and rename the manual-init switch
edgchen1 Sep 3, 2026
c1bc945
Make OrtEnv::GetOrCreateInstance exception safe
edgchen1 Sep 3, 2026
ca1dde1
Select every matching device in the wasm OrtAppendExecutionProviderV2
edgchen1 Sep 3, 2026
31530b5
Record the PR review feedback round in the work log
edgchen1 Sep 3, 2026
53bf498
Pass EP devices explicitly to the wasm OrtAppendExecutionProviderV2
edgchen1 Sep 3, 2026
69d8fc3
Record end-to-end verification of the EP-device-array path
edgchen1 Sep 3, 2026
765c59a
Select a single EP device when appending the WebGPU plugin EP
edgchen1 Sep 3, 2026
c6ba17d
Record re-verification of the single-device EP selection
edgchen1 Sep 3, 2026
6fd4ff1
Rename api.h skip init macro to ORT_PLUGIN_EP_SKIP_API_MANUAL_INIT, u…
edgchen1 Sep 4, 2026
c2a6d47
docs: cover native runtime performance and conformance in success cri…
edgchen1 Sep 4, 2026
873f221
Merge remote-tracking branch 'origin/edgchen1/webgpu_ep_extraction_pl…
edgchen1 Sep 4, 2026
4aef27c
Add native plugin EP latency measurement setup and environment findings
edgchen1 Sep 4, 2026
2a69c35
Update native latency doc: f16 GPU restored, measurement unblocked
edgchen1 Sep 4, 2026
ebe31d5
Document build fairness controls for the native latency A/B
edgchen1 Sep 5, 2026
1cfea6f
Record native built-in vs plugin EP latency A/B results
edgchen1 Sep 8, 2026
89b5144
Log the native plugin latency A/B in the work log
edgchen1 Sep 8, 2026
a888054
Record CPU profile root-causing the native plugin EP per-node overhead
edgchen1 Sep 8, 2026
3a01ce0
Record that the adapter-overhead hypothesis was tested and did not hold
edgchen1 Sep 9, 2026
475f2cb
Update WASM size comparison with both shipped WebGPU artifacts
edgchen1 Sep 9, 2026
5a84e15
Restrict Environment::CreateAndRegisterStaticPluginEps to OrtEnv via …
edgchen1 Sep 9, 2026
c32806d
Correct the stale self-deadlock comment on CreateAndRegisterInternalEps
edgchen1 Sep 9, 2026
c708345
Address PR review comments on code comments
edgchen1 Sep 9, 2026
e2915c6
Select the WebGPU EP by OrtEpDevice without claiming it is a plugin EP
edgchen1 Sep 9, 2026
be8f755
Merge remote-tracking branch 'origin/main' into edgchen1/webgpu_stati…
edgchen1 Sep 10, 2026
21abbc6
Document OrtEpFactory::GetSupportedDevices constraints
edgchen1 Sep 10, 2026
30401ea
Merge remote-tracking branch 'origin/main' into edgchen1/webgpu_stati…
edgchen1 Sep 10, 2026
cadd1a5
docs: record remaining WebGPU consumers and simplify the disposition …
edgchen1 Sep 10, 2026
bbcbed8
Fold work-log performance follow-ups into the design doc
edgchen1 Sep 10, 2026
1d577c8
Drop the work log and native measurement notes from the PR
edgchen1 Sep 10, 2026
2ac50a1
Always pass the WebGPU plugin EP CMake flags explicitly
edgchen1 Sep 11, 2026
ad2413a
Add a build-only WASM static plugin EP CI leg
edgchen1 Sep 11, 2026
1aa7d11
Correct factual errors in the static plugin EP design docs
edgchen1 Sep 11, 2026
c642429
Split the static plugin EP design doc into design, validation and mig…
edgchen1 Sep 11, 2026
1bae783
Record per-package status in the plugin boundary workstream
edgchen1 Sep 11, 2026
d8f69c1
Narrow the plugin boundary workstream open questions to what is actua…
edgchen1 Sep 11, 2026
8ba6c3f
Close out the plugin boundary workstream open questions
edgchen1 Sep 11, 2026
0bd98b7
docs: consolidate static plugin EP design
edgchen1 Sep 11, 2026
5fd229e
docs: streamline static plugin EP design
edgchen1 Sep 12, 2026
9535283
Merge remote-tracking branch 'origin/main' into edgchen1/webgpu_stati…
edgchen1 Sep 12, 2026
4cc65eb
trim comment
edgchen1 Sep 14, 2026
f581951
fix cmake option comment
edgchen1 Sep 14, 2026
b99d116
update GetSupportedDevices comment
edgchen1 Sep 14, 2026
2f01282
clarify comment for KernelInfoGetAttribute_string
edgchen1 Sep 14, 2026
3fd1009
Clarify Emscripten WebGPU discovery in Node.js
edgchen1 Sep 14, 2026
c7e06cd
Address static plugin EP review feedback
edgchen1 Sep 14, 2026
16fa85f
Fix WASM device discovery test failure
edgchen1 Sep 15, 2026
427d2ea
Make plugin EP registration failure-safe
edgchen1 Sep 23, 2026
ca3b314
update comment
edgchen1 Sep 23, 2026
1e53cbc
update
edgchen1 Sep 23, 2026
55f5432
Merge remote-tracking branch 'origin/main' into edgchen1/webgpu_stati…
edgchen1 Sep 23, 2026
b4070c9
fix compile issue
edgchen1 Sep 23, 2026
d72042e
Fix plugin data transfer ownership test
edgchen1 Sep 23, 2026
f393cb8
fix build issue, update EpInfo::Create to set output ptr iff successful.
edgchen1 Sep 23, 2026
07d5b4b
Fix plugin EP allocator callback validation
edgchen1 Sep 28, 2026
ece1310
Trim GetSupportedDevices API remarks
edgchen1 Sep 28, 2026
fccebe9
Reuse status conversion helper in EP adapter
edgchen1 Sep 28, 2026
e1243ae
fix formatting, remove old comment
edgchen1 Sep 29, 2026
be525cc
Replace old use of routing_record with routing_snapshot_.
edgchen1 Sep 29, 2026
503e433
Replace old use of routing_record with routing_snapshot_.
edgchen1 Sep 29, 2026
9d5c576
Fix packed QMoE expert snapshot capture
edgchen1 Sep 29, 2026
ad7818d
Merge remote-tracking branch 'origin/edgchen1/fix_cuda_moe_quantizati…
edgchen1 Sep 29, 2026
166182c
Merge remote-tracking branch 'origin/main' into edgchen1/webgpu_stati…
edgchen1 Sep 30, 2026
5ecef0f
simplify ifdefs
edgchen1 Sep 30, 2026
2cb6718
Handle WebGPU initialization edge cases
edgchen1 Oct 1, 2026
f9b826f
Merge remote-tracking branch 'origin/main' into edgchen1/webgpu_stati…
edgchen1 Oct 1, 2026
e064456
remove old yaml template reference
edgchen1 Oct 1, 2026
665e978
increase Android minimal baseline build binary size threshold to 1601536
edgchen1 Oct 1, 2026
6b02a61
Ignore virtual devices in WebGPU allocator tests
edgchen1 Oct 2, 2026
3bd332d
Fix WebGPU test provider option ambiguity
edgchen1 Oct 2, 2026
7422330
Fix Linux WebGPU static plugin test build
edgchen1 Oct 2, 2026
25ca2af
Add WebGPU EP GetDawnPlatform() known memory leak to debug_alloc.cc e…
edgchen1 Oct 2, 2026
df7e3f8
Merge branch 'edgchen1/webgpu_static_plugin' of https://github.com/mi…
edgchen1 Oct 2, 2026
d9cf06a
revert binary size threshold update
edgchen1 Oct 3, 2026
bd59856
Merge remote-tracking branch 'origin/main' into edgchen1/webgpu_stati…
edgchen1 Oct 3, 2026
7e99529
Revert "revert binary size threshold update"
edgchen1 Oct 3, 2026
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
5 changes: 3 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ jobs:
run: |
set -e -x
BINARY_SIZE_THRESHOLD_ARGS=""
echo "Binary size threshold in bytes: 1599488"
BINARY_SIZE_THRESHOLD_ARGS="--threshold_size_in_bytes 1599488"
BINARY_SIZE_THRESHOLD_IN_BYTES=1601536
echo "Binary size threshold in bytes: ${BINARY_SIZE_THRESHOLD_IN_BYTES}"
BINARY_SIZE_THRESHOLD_ARGS="--threshold_size_in_bytes ${BINARY_SIZE_THRESHOLD_IN_BYTES}"

# Ensure ANDROID_NDK_HOME is available and get its real path
if [ -z "$ANDROID_NDK_HOME" ]; then
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/linux-wasm-ci-build-and-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ on:
required: false
type: boolean
default: false
build_webgpu_static_plugin:
required: false
type: boolean
default: false

jobs:
build-wasm:
Expand Down Expand Up @@ -159,6 +163,24 @@ jobs:
--skip_tests
working-directory: ${{ github.workspace }}

# Build-only coverage for registering the WebGPU EP as a statically linked plugin EP under Emscripten.
# The output is deliberately not published: it has the same file names as the published WebGPU build, and
# the ORT Web test harness selects the wasm binary by file name, so both variants cannot ship together.
# This leg becomes redundant once the published WebGPU wasm build switches over to the plugin EP.
- name: Build (simd + threads + WebGPU experimental, static plugin EP)
if: ${{ inputs.build_webgpu_static_plugin == true }}
run: |
python ./tools/ci_build/build.py \
${{ env.common_build_args }} \
--build_dir ${{ github.workspace }}/build/wasm_inferencing_webgpu_static_plugin \
--use_webgpu static_plugin \
--use_webnn \
--target onnxruntime_webassembly \
${{ inputs.build_config == 'Release' && '--enable_wasm_api_exception_catching' || '' }} \
${{ env.reduced_size_build_args }} \
--skip_tests
working-directory: ${{ github.workspace }}

- name: Create Artifacts
if: ${{ inputs.skip_publish != true }}
run: |
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/linux_webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ jobs:
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Pass token for reusable workflow needs (e.g., docker build action)

# Builds the same WebGPU plugin EP sources linked into the ORT binary rather than as a separate
# shared library. Build-only, like the job above; this exists mainly to compile the static plugin
# configuration with GCC as well as MSVC. See docs/design/webgpu_ep_extraction/
# plugin_boundary_and_web_integration/static_plugin_ep_registration_design.md
build-linux-webgpu-static-plugin-x64-release:
name: Build Linux WebGPU Static Plugin x64 Release
uses: ./.github/workflows/reusable_linux_build.yml
with:
pool_name: "onnxruntime-github-Ubuntu2204-AMD-CPU" # Build pool
build_config: Release
architecture: x64
dockerfile_path: tools/ci_build/github/linux/docker/Dockerfile.manylinux2_28_webgpu
docker_image_repo: onnxruntimecpubuildpythonx64
extra_build_flags: '--use_binskim_compliant_compile_flags --build_wheel --use_webgpu static_plugin --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=ON'
Comment thread
edgchen1 marked this conversation as resolved.
Resolved
python_path_prefix: 'PATH=/opt/python/cp310-cp310/bin:$PATH'
run_tests: false
upload_build_output: false
execution_providers: 'webgpu'
job_identifier: build-linux-webgpu-static-plugin-x64-release
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Pass token for reusable workflow needs (e.g., docker build action)

# TODO: the following test step is currently failing. Need to fix and re-enable it

# test-linux-webgpu-x64-release:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
extra_build_args: "--target onnxruntime_webassembly --skip_tests --disable_rtti"
build_jsep: true
build_webgpu: true
build_webgpu_static_plugin: true

wasm_Release_static_library:
needs: precheck
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/windows_webgpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,77 @@ jobs:
exit $lastExitCode
}

# Same plugin EP sources as webgpu_plugin_build_x64_RelWithDebInfo, but linked into the ORT binary
# instead of built as a separate shared library.
webgpu_static_plugin_build_x64_RelWithDebInfo:
runs-on: [
"self-hosted",
"1ES.Pool=onnxruntime-github-Win2022-GPU-A10",
"JobId=webgpu_static_plugin_build_x64_RelWithDebInfo-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"
]
timeout-minutes: 300
env:
OnnxRuntimeBuildDirectory: ${{ github.workspace }}
setVcvars: true
ALLOW_RELEASED_ONNX_OPSET_ONLY: "0"
DocUpdateNeeded: false
NVIDIA_TF32_OVERRIDE: "0"
ONNXRUNTIME_TEST_GPU_DEVICE_ID: "0"
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: none

- name: Setup Python 3.12
uses: actions/setup-python@v6
with:
python-version: "3.12"
architecture: x64

- name: Locate vcvarsall and Setup Env
uses: ./.github/actions/locate-vcvarsall-and-setup-env
with:
architecture: x64

- name: Install python modules
run: python -m pip install -r tools\ci_build\github\windows\python\requirements.txt
shell: cmd
working-directory: ${{ github.workspace }}

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: "20.x"

- uses: actions/cache@v5
id: onnx-node-tests-cache
with:
path: ${{ github.workspace }}/js/test/
key: onnxnodetests-${{ hashFiles('js/scripts/prepare-onnx-node-tests.ts') }}

# onnxruntime_BUILD_DAWN_SHARED_LIBRARY is deliberately not enabled here. It is incompatible with
# onnxruntime_USE_EP_API_ADAPTERS, which --use_webgpu static_plugin turns on.
- name: Build and Test
shell: pwsh
run: |
python.exe ${{ github.workspace }}\tools\ci_build\build.py `
--config RelWithDebInfo `
--build_dir ${{ github.workspace }} `
--skip_submodule_sync `
--parallel `
--use_binskim_compliant_compile_flags `
--cmake_generator "Visual Studio 17 2022" `
--enable_onnx_tests `
--use_webgpu static_plugin `
--use_vcpkg --use_vcpkg_ms_internal_asset_cache `
--cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=ON onnxruntime_ENABLE_DAWN_BACKEND_D3D12=1 onnxruntime_ENABLE_DAWN_BACKEND_VULKAN=1

if ($lastExitCode -ne 0) {
exit $lastExitCode
}

webgpu_external_dawn_build_x64_RelWithDebInfo:
runs-on: [
"self-hosted",
Expand Down
31 changes: 30 additions & 1 deletion cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ option(onnxruntime_USE_CANN "Build with CANN support" OFF)
option(onnxruntime_USE_XNNPACK "Build with XNNPACK support. Provides an alternative math library on ARM, WebAssembly and x86." OFF)
option(onnxruntime_USE_WEBNN "Build with WebNN support. Enable hardware acceleration in web browsers." OFF)
option(onnxruntime_USE_WEBGPU "Build with WebGPU support. Enable WebGPU via C/C++ interface." OFF)
option(onnxruntime_USE_EP_API_ADAPTERS "Build EP (e.g. WebGPU) as a plugin EP shared library using EP API adapters" OFF)
option(onnxruntime_USE_EP_API_ADAPTERS "Build EP (e.g. WebGPU) as a plugin EP library using EP API adapters" OFF)
option(onnxruntime_WEBGPU_STATIC_PLUGIN "Build the WebGPU plugin EP into the ORT binary instead of a separate shared library. Requires onnxruntime_USE_EP_API_ADAPTERS." OFF)
option(onnxruntime_USE_EXTERNAL_DAWN "Build with treating Dawn as external dependency. Will not link Dawn at build time." OFF)
option(onnxruntime_CUSTOM_DAWN_SRC_PATH "Path to custom Dawn src dir.")
set(onnxruntime_DAWN_PREBUILT_DIR "" CACHE PATH "Directory containing Dawn headers and standalone proc sources for external Dawn")
Expand Down Expand Up @@ -456,6 +457,34 @@ if(onnxruntime_USE_EP_API_ADAPTERS)
add_compile_definitions(ORT_USE_EP_API_ADAPTERS=1)
endif()

# The WebGPU plugin EP can either be a separate shared library or be linked into the ORT binary. In the latter case
# ORT core registers it at OrtEnv creation time instead of the application loading it by path.
if(onnxruntime_WEBGPU_STATIC_PLUGIN)
if(NOT onnxruntime_USE_WEBGPU)
message(FATAL_ERROR "onnxruntime_WEBGPU_STATIC_PLUGIN=ON requires onnxruntime_USE_WEBGPU=ON.")
endif()
if(NOT onnxruntime_USE_EP_API_ADAPTERS)
message(FATAL_ERROR "onnxruntime_WEBGPU_STATIC_PLUGIN=ON requires onnxruntime_USE_EP_API_ADAPTERS=ON.")
endif()
# A minimal build excludes core/session/plugin_ep, so the registration that a static plugin EP depends on is not
# compiled in. Without this check the EP would be linked into the binary but never registered, with no diagnostic
# at configure, build or run time. Supporting the combination is possible but requires making the plugin EP
# registration available to minimal builds first.
if(onnxruntime_MINIMAL_BUILD)
message(FATAL_ERROR "onnxruntime_WEBGPU_STATIC_PLUGIN=ON is not supported in a minimal build: the plugin EP "
"registration in core/session/plugin_ep is excluded, so the EP would be linked in but "
"never registered.")
endif()
add_compile_definitions(ORT_WEBGPU_STATIC_PLUGIN=1)
endif()

# True when the WebGPU EP is compiled into the ORT binary rather than built as a separate shared library.
if(onnxruntime_USE_WEBGPU AND (NOT onnxruntime_USE_EP_API_ADAPTERS OR onnxruntime_WEBGPU_STATIC_PLUGIN))
set(onnxruntime_WEBGPU_LINKED_INTO_HOST ON)
else()
set(onnxruntime_WEBGPU_LINKED_INTO_HOST OFF)
endif()

# General C# properties
if (onnxruntime_BUILD_CSHARP)
check_language(CSharp)
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ if (onnxruntime_BUILD_QNN_EP_STATIC_LIB)
list(APPEND onnxruntime_INTERNAL_PROVIDER_LIBRARIES onnxruntime_providers_qnn)
endif()

if (onnxruntime_USE_WEBGPU AND NOT onnxruntime_USE_EP_API_ADAPTERS)
if (onnxruntime_WEBGPU_LINKED_INTO_HOST)
list(APPEND onnxruntime_INTERNAL_PROVIDER_LIBRARIES onnxruntime_providers_webgpu)
endif()

Expand Down
3 changes: 3 additions & 0 deletions cmake/onnxruntime_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ elseif (LINUX)
elseif (APPLE)
list(APPEND onnxruntime_common_src_patterns
"${ONNXRUNTIME_ROOT}/core/platform/apple/device_discovery.cc")
elseif (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
list(APPEND onnxruntime_common_src_patterns
"${ONNXRUNTIME_ROOT}/core/platform/emscripten/device_discovery.cc")
else()
list(APPEND onnxruntime_common_src_patterns
"${ONNXRUNTIME_ROOT}/core/platform/device_discovery_default.cc")
Expand Down
92 changes: 63 additions & 29 deletions cmake/onnxruntime_providers_webgpu.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

if(NOT onnxruntime_USE_EP_API_ADAPTERS)
#
# Build WebGPU EP as a static library
# Build WebGPU EP as an internal (non-plugin) static library
#

# For static library build, exclude the 'ep' folder
Expand All @@ -39,6 +39,24 @@
onnxruntime_add_static_library(onnxruntime_providers_webgpu ${onnxruntime_providers_webgpu_cc_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_webgpu
onnxruntime_common onnx onnx_proto flatbuffers::flatbuffers Boost::mp11 safeint_interface)
elseif(onnxruntime_WEBGPU_STATIC_PLUGIN)
#
# Build WebGPU EP as a plugin EP that is statically linked into the ORT binary.
#
# This uses the same plugin EP sources ('ep' folder) and EP API adapters as the shared library build below.
# The difference is only in how the EP reaches the application: ORT core registers it at OrtEnv creation time
# instead of the application calling RegisterExecutionProviderLibrary() with a library path.
#
source_group(TREE ${ONNXRUNTIME_ROOT} FILES ${onnxruntime_providers_webgpu_cc_srcs})
onnxruntime_add_static_library(onnxruntime_providers_webgpu ${onnxruntime_providers_webgpu_cc_srcs})
onnxruntime_add_include_to_target(onnxruntime_providers_webgpu
onnxruntime_common onnx onnx_proto flatbuffers::flatbuffers Boost::mp11 safeint_interface)

# ORT_PLUGIN_EP_SKIP_API_MANUAL_INIT tells the shared plugin EP headers that OrtGetApiBase() is available
# in-process, so the C++ API must not be built with ORT_API_MANUAL_INIT (the rest of the binary is not).
target_compile_definitions(onnxruntime_providers_webgpu PRIVATE
ORT_PLUGIN_EP_STATICALLY_LINKED=1
ORT_PLUGIN_EP_SKIP_API_MANUAL_INIT=1)
else()
#
# Build WebGPU EP as a shared library
Expand Down Expand Up @@ -77,27 +95,6 @@
add_definitions("-DONNX_NAMESPACE=onnx")
add_definitions("-DONNX_USE_LITE_PROTO=1")

# Default plugin EP version to ORT_VERSION with "-dev" suffix if not explicitly provided.
if(NOT DEFINED onnxruntime_PLUGIN_EP_VERSION)
set(onnxruntime_PLUGIN_EP_VERSION "${ORT_VERSION}-dev")
endif()

# Set preprocessor definition for plugin EP version
target_compile_definitions(onnxruntime_providers_webgpu PRIVATE
ORT_PLUGIN_EP_VERSION="${onnxruntime_PLUGIN_EP_VERSION}")

# Bake the minimum compatible ORT version (the single source of truth lives in
# plugin-ep-webgpu/MIN_ONNXRUNTIME_VERSION) into the EP DLL so it can be enforced at runtime.
# Format is strict "MAJOR.MINOR.PATCH".
set(_ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION_FILE "${REPO_ROOT}/plugin-ep-webgpu/MIN_ONNXRUNTIME_VERSION")
file(STRINGS "${_ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION_FILE}" _ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION LIMIT_COUNT 1)
if(NOT _ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION)
message(FATAL_ERROR "WebGPU plugin EP minimum ORT version file is missing or empty: "
"${_ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION_FILE}")
endif()
target_compile_definitions(onnxruntime_providers_webgpu PRIVATE
ORT_PLUGIN_EP_MIN_ORT_VERSION="${_ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION}")

# Set preprocessor definitions used in onnxruntime_providers_webgpu.rc
if(WIN32)
set(WEBGPU_DLL_FILE_DESCRIPTION "ONNX Runtime WebGPU Provider")
Expand Down Expand Up @@ -131,14 +128,50 @@
message(FATAL_ERROR "WebGPU EP shared library build does not support build cache. Please disable build cache or use static library build.")
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
message(FATAL_ERROR "WebGPU EP shared library build is not supported on Emscripten. Please use static library build.")
message(FATAL_ERROR "WebGPU EP shared library build is not supported on Emscripten. Please use '--use_webgpu static_plugin'.")
endif()
endif()

if (onnxruntime_USE_EP_API_ADAPTERS)
#
# Settings common to both plugin EP builds (shared library and statically linked).
#

# Default plugin EP version to ORT_VERSION with "-dev" suffix if not explicitly provided.
if(NOT DEFINED onnxruntime_PLUGIN_EP_VERSION)
set(onnxruntime_PLUGIN_EP_VERSION "${ORT_VERSION}-dev")
endif()

# Configure precompiled headers for shared library build
# PCH ensures ep/adapters.h is included first and improves compilation speed
# Set preprocessor definition for plugin EP version
target_compile_definitions(onnxruntime_providers_webgpu PRIVATE
ORT_PLUGIN_EP_VERSION="${onnxruntime_PLUGIN_EP_VERSION}")

# Bake the minimum compatible ORT version (the single source of truth lives in
# plugin-ep-webgpu/MIN_ONNXRUNTIME_VERSION) into the EP so it can be enforced at runtime.
# Format is strict "MAJOR.MINOR.PATCH".
set(_ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION_FILE "${REPO_ROOT}/plugin-ep-webgpu/MIN_ONNXRUNTIME_VERSION")
file(STRINGS "${_ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION_FILE}" _ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION LIMIT_COUNT 1)
if(NOT _ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION)
message(FATAL_ERROR "WebGPU plugin EP minimum ORT version file is missing or empty: "
"${_ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION_FILE}")
endif()
target_compile_definitions(onnxruntime_providers_webgpu PRIVATE
ORT_PLUGIN_EP_MIN_ORT_VERSION="${_ORT_PLUGIN_EP_WEBGPU_MIN_ORT_VERSION}")

# Configure precompiled headers for the plugin EP build.
# PCH ensures ep/adapters.h is included first and improves compilation speed.
target_precompile_headers(onnxruntime_providers_webgpu PRIVATE
"${REPO_ROOT}/include/onnxruntime/ep/adapters.h"
)

# Suppress -Werror=maybe-uninitialized. The EP adapter types are defined entirely inline in headers,
# so GCC sees through the failure and exception paths of accessors like OpKernelInfo::GetAttr<> and
# falsely warns about values that are only read once the call has succeeded. It also produces false
# positives deep inside absl::InlinedVector for locals that are always constructed.
# This mirrors the same suppression on the CUDA plugin EP target.
target_compile_options(onnxruntime_providers_webgpu PRIVATE
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>>:-Wno-maybe-uninitialized>
Comment thread
edgchen1 marked this conversation as resolved.
Resolved
)
endif()

set_target_properties(onnxruntime_providers_webgpu PROPERTIES CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -261,13 +294,14 @@
endif()
endif()

# In the plugin/adapter build (onnxruntime_USE_EP_API_ADAPTERS) the WebGPU EP is its own DLL
# (onnxruntime_providers_webgpu.dll) rather than being statically linked into onnxruntime.dll, so the
# In the plugin EP shared library build the WebGPU EP is its own DLL
# (onnxruntime_providers_webgpu.dll) rather than being linked into onnxruntime.dll, so the
# delay-load flags accumulated above (notably /DELAYLOAD:user32.dll) must be applied to THIS target.
# Without it the DLL keeps a static import on user32.dll and fails to load in a Win32k-lockdown sandbox
# (e.g. Chromium's WebNN compiler process): 'depends on "USER32.dll" which is missing' (Error 1359).
# In the static build these same flags are applied to the onnxruntime target in onnxruntime.cmake.
if (WIN32 AND onnxruntime_USE_EP_API_ADAPTERS AND onnxruntime_DELAYLOAD_FLAGS)
# When the EP is linked into the ORT binary these same flags are applied to the onnxruntime target in
# onnxruntime.cmake.
if (WIN32 AND NOT onnxruntime_WEBGPU_LINKED_INTO_HOST AND onnxruntime_DELAYLOAD_FLAGS)
target_link_options(onnxruntime_providers_webgpu PRIVATE ${onnxruntime_DELAYLOAD_FLAGS})
target_link_libraries(onnxruntime_providers_webgpu PRIVATE delayimp.lib)
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/onnxruntime_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ set(onnxruntime_pybind11_state_static_providers
if(onnxruntime_BUILD_QNN_EP_STATIC_LIB)
list(APPEND onnxruntime_pybind11_state_static_providers PRIVATE onnxruntime_providers_qnn)
endif()
if(onnxruntime_USE_WEBGPU AND NOT onnxruntime_USE_EP_API_ADAPTERS)
if(onnxruntime_WEBGPU_LINKED_INTO_HOST)
list(APPEND onnxruntime_pybind11_state_static_providers PRIVATE onnxruntime_providers_webgpu)
endif()
if(WIN32)
Expand Down
Loading