[WebGPU EP] Reduce forward declaration boilerplate in kernel registration#27977
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors WebGPU EP kernel registration to eliminate large blocks of redundant forward declarations by using elaborated type specifiers (class ...) directly in BuildKernelCreateInfo<...> entries, and moving the function pointer tables to namespace scope to ensure the introduced declarations have external linkage.
Changes:
- Replace explicit forward-declaration lists with
BuildKernelCreateInfo<class ONNX_OPERATOR_...>usage. - Move kernel create-info function tables out of function scope and reuse them in registration loops.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc | Moves WebGPU kernel create-info function table to namespace scope and removes forward-declaration boilerplate via class in template arguments. |
| onnxruntime/contrib_ops/webgpu/webgpu_contrib_kernels.cc | Applies the same pattern for WebGPU contrib kernel registration by hoisting the function table and removing forward declarations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
guschmue
previously approved these changes
Apr 7, 2026
Contributor
Author
|
will do this cleanup after 1.25 |
…larations Use inline 'class' elaborated-type-specifiers in BuildKernelCreateInfo<> template arguments to combine forward declarations with table entries. Move function_table from function-local static to file scope and rename to build_kernel_create_info_function_table. Affects webgpu_execution_provider.cc (~220 forward declarations removed) and webgpu_contrib_kernels.cc (~22 forward declarations removed).
1d3156d to
caa13be
Compare
…fine_kernel_registration
guschmue
approved these changes
Apr 16, 2026
Contributor
Author
|
/azp run Windows ARM64 QNN CI Pipeline |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Update WebGPU EP kernel registration to remove redundant forward declarations.
E.g., change from this:
to this:
One subtlety is that the function table needs to be moved outside of the function now, since function-local (block scope) forward declarations would introduce names with no linkage. Those names should have external linkage.
We already do something similar here:
onnxruntime/onnxruntime/test/autoep/library/example_plugin_ep_kernel_registry/ep_kernel_registration.cc
Line 12 in aaa4944
Motivation and Context
Reduce boilerplate.