-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[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
base: main
Are you sure you want to change the base?
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.
Description
refactor initialization of WebGPU Context params
The refactor:
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().Motivation and Context