Skip to content

[webgpu] revise class ComputeContext in WebGPU EP - #26552

Merged
Yulong Wang (fs-eire) merged 2 commits into
microsoft:mainfrom
fs-eire:fs-eire/revise-compute-context-class
Nov 13, 2025
Merged

[webgpu] revise class ComputeContext in WebGPU EP#26552
Yulong Wang (fs-eire) merged 2 commits into
microsoft:mainfrom
fs-eire:fs-eire/revise-compute-context-class

Conversation

@fs-eire

Copy link
Copy Markdown
Contributor

Description

revise class ComputeContext in WebGPU EP.

Avoid potential access to ComputeContext::BufferManager, which may cause it very difficult to diagnose buffer memory issue.

@fs-eire

Copy link
Copy Markdown
Contributor Author

/azp run Linux QNN CI Pipeline, Win_TRT_Minimal_CUDA_Test_CI, Windows ARM64 QNN CI Pipeline, Windows GPU Doc Gen CI Pipeline

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 4 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 ComputeContext class in the WebGPU execution provider to prevent direct access to the BufferManager, improving encapsulation and making buffer memory issues easier to diagnose.

Key changes:

  • Moved WebGpuContext retrieval and error scope management from ComputeContext to WebGpuKernel::Compute
  • Introduced BufferManagerAccessor nested class with friend access to restrict BufferManager access to WebGpuContext only
  • Updated ComputeContext constructor to accept WebGpuContext& as a parameter instead of fetching it internally

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
webgpu_kernel.h Moved constructor and Compute method implementations from inline to separate .cc file
webgpu_kernel.cc Implemented WebGpuKernel constructor and Compute method with validation mode error scope handling
webgpu_context.cc Updated BufferManager access to use BufferManagerAccessor
compute_context.h Added BufferManagerAccessor nested class and updated constructor signature
compute_context.cc Simplified implementation with new constructor and BufferManagerAccessor::Get method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fs-eire
Yulong Wang (fs-eire) merged commit 43568cb into microsoft:main Nov 13, 2025
91 of 93 checks passed
Rohanjames1997 pushed a commit to Rohanjames1997/onnxruntime that referenced this pull request Dec 4, 2025
### Description

 revise class ComputeContext in WebGPU EP.

Avoid potential access to `ComputeContext::BufferManager`, which may
cause it very difficult to diagnose buffer memory issue.
Sumit Kumar (Sumit2318) pushed a commit that referenced this pull request Jan 6, 2026
### Description

 revise class ComputeContext in WebGPU EP.

Avoid potential access to `ComputeContext::BufferManager`, which may
cause it very difficult to diagnose buffer memory issue.
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