Skip to content

Conversation

fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Aug 7, 2025

Description

add usage of ReadonlyAllocator for WebGPU EP

Motivation and Context

ReadonlyAllocator is added in #25348 to allow an EP to register a separated allocator only use for initializers.

WebGPU EP already has different handling to initializers and non-initializers, and this change makes WebGPU EP to use the preferred way to deal with it. Now the allocator depends on the OrtAllocatorType instead of the session initialization status.

@guschmue guschmue added the ep:WebGPU ort-web webgpu provider label Aug 8, 2025
@fs-eire fs-eire requested review from skottmckay and Copilot August 8, 2025 18:30
Copy link
Contributor

@Copilot 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 integrates the WebGPU execution provider with the ReadonlyAllocator pattern introduced in PR #25348, allowing separate allocators for initializers versus regular operations. The change makes the allocator type depend on OrtAllocatorType rather than session initialization status.

Key changes:

  • Creates two separate allocators in CreatePreferredAllocators() - one for read-only initializers and one for regular operations
  • Adds a dedicated initializer buffer manager to WebGpuContext
  • Simplifies the BufferManager::Create() method by consolidating UMA buffer creation logic

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
webgpu_execution_provider.h Removes session initialization callback and allocator member variable
webgpu_execution_provider.cc Updates allocator creation to use two separate allocators and removes session initialization handling
webgpu_context.h Adds initializer buffer manager accessor and documentation
webgpu_context.cc Creates dedicated initializer buffer manager with disabled caching
buffer_manager.h Removes CreateUMA method and simplifies Create method signature
buffer_manager.cc Consolidates UMA buffer creation logic into the main Create method
allocator.h Updates constructor to accept read-only flag and removes session initialization method
allocator.cc Implements read-only allocator logic and consolidates buffer creation

@fs-eire fs-eire merged commit 063491c into main Aug 11, 2025
94 of 98 checks passed
@fs-eire fs-eire deleted the fs-eire/use-readonly-allocator branch August 11, 2025 21:30
gedoensmax pushed a commit to gedoensmax/onnxruntime that referenced this pull request Sep 2, 2025
### Description

add usage of `ReadonlyAllocator` for WebGPU EP


### Motivation and Context

`ReadonlyAllocator` is added in microsoft#25348 to allow an EP to register a
separated allocator only use for initializers.

WebGPU EP already has different handling to initializers and
non-initializers, and this change makes WebGPU EP to use the preferred
way to deal with it. Now the allocator depends on the `OrtAllocatorType`
instead of the session initialization status.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ep:WebGPU ort-web webgpu provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants