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 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().
  • 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

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.

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.

2 participants