-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[webgpu] refactor initialization of WebGPU Context params #26855
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the initialization of WebGPU context parameters to improve code organization and consistency. The refactoring splits configuration into three distinct classes: WebGpuExecutionProviderConfig for execution provider settings, WebGpuContextCreationParams for context construction parameters, and WebGpuContextInitializationParams for context initialization parameters. All configuration classes now use default member initialization, and option parsing logic has been centralized into dedicated parsing functions.
Key changes:
- Introduced three separate configuration structs with default member initialization replacing the previous single config struct and separate parameter handling
- Centralized option parsing into
ParseEpConfig,ParseWebGpuContextCreationParams, andParseWebGpuContextInitializationParamsfunctions - Removed
power_preferencefromWebGpuContextconstructor and moved it to initialization parameters
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| webgpu_provider_factory.cc | Refactored configuration parsing into three separate functions and updated factory creation logic to use new parameter structs |
| webgpu_execution_provider.h | Simplified WebGpuExecutionProviderConfig struct to use default member initialization instead of constructor |
| webgpu_context.h | Introduced WebGpuContextCreationParams and WebGpuContextInitializationParams structs with default initialization; updated WebGpuBufferCacheConfig |
| webgpu_context.cc | Updated Initialize and CreateContext methods to accept new parameter structs instead of individual parameters |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1bc74c4 to
e30a148
Compare
|
Updated the PR to make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
### Description As a following-up of #26855, this PR changes the PIX fram generator from per-WebGpuContext to per inference session, to support more flexible control for performance diagnositcs. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
…26855) ### Description refactor initialization of WebGPU Context params The refactor: - makes all WebGPU options into ~~3~~ 2 classes: - `WebGpuExecutionProviderConfig`: configuration that passed to and stored inside the EP class. - ~~`WebGpuContextCreationParams`: configuration that passed to constructor of class `WebGpuContext`.~~ - ~~`WebGpuContextInitializationParams`: configuration that passed to `WebGpuContext::Initialize()`.~~ - `WebGpuContextConfig`: configuration that passed to construct and initialize `WebGpuContext`. - ensure all instance of the classes are created with default value initialized. - ensure all of the following happens only at one place: - setting default value - parse option - add `WebGpuContextFactory::DefaultContext` to allow "get or create" the default context. ### Motivation and Context - Make code more clean and consistent. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
### Description As a following-up of microsoft#26855, this PR changes the PIX fram generator from per-WebGpuContext to per inference session, to support more flexible control for performance diagnositcs. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
Description
refactor initialization of WebGPU Context params
The refactor:
32 classes:WebGpuExecutionProviderConfig: configuration that passed to and stored inside the EP class.WebGpuContextCreationParams: configuration that passed to constructor of classWebGpuContext.WebGpuContextInitializationParams: configuration that passed toWebGpuContext::Initialize().WebGpuContextConfig: configuration that passed to construct and initializeWebGpuContext.WebGpuContextFactory::DefaultContextto allow "get or create" the default context.Motivation and Context