Skip to content

Conversation

@fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Dec 23, 2025

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.

Copy link
Contributor

Copilot AI left a 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, and ParseWebGpuContextInitializationParams functions
  • Removed power_preference from WebGpuContext constructor 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.

fs-eire and others added 2 commits December 22, 2025 18:39
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a 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.

@fs-eire fs-eire force-pushed the fs-eire/refactor-webgpu-context-init branch from 1bc74c4 to e30a148 Compare December 24, 2025 04:35
guschmue
guschmue previously approved these changes Dec 24, 2025
@fs-eire
Copy link
Contributor Author

fs-eire commented Dec 27, 2025

Updated the PR to make WebGpuContextCreationParams and WebGpuContextInitializationParams into a single class WebGpuContextConfig.

Copy link
Contributor

Copilot AI left a 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.

@fs-eire fs-eire merged commit 2f0eb77 into main Dec 29, 2025
108 of 109 checks passed
@fs-eire fs-eire deleted the fs-eire/refactor-webgpu-context-init branch December 29, 2025 09:12
guschmue pushed a commit that referenced this pull request Dec 30, 2025
### 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. -->
alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request Jan 20, 2026
…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>
alex-spacemit pushed a commit to spacemit-com/onnxruntime that referenced this pull request Jan 20, 2026
### 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. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants