Skip to content

Support read-only allocator for use with initializers - #25348

Merged
George Wu (jywu-mysoft) merged 5 commits into
mainfrom
skottmckay/AddSupportForReadOnlyAllocatorToBeUsedWithInitializers
Jul 24, 2025
Merged

George Wu (jywu-mysoft) merged 5 commits into
mainfrom
skottmckay/AddSupportForReadOnlyAllocatorToBeUsedWithInitializers

Conversation

@skottmckay

Copy link
Copy Markdown
Contributor

Description

Add new allocator type of OrtReadOnlyAllocator to enable providing a separate allocator that is only used for initializers.

Update the SessionState logic to support this allocator type being provided, and use it when doing device allocations for initializers.

Motivation and Context

Performance.

…separate allocator that is only used for initializers.

Update the SessionState logic to support this allocator type being provided, and use it when doing device allocations for initializers.
@skottmckay
Scott McKay (skottmckay) marked this pull request as ready for review July 20, 2025 00:38
@fs-eire

Copy link
Copy Markdown
Contributor

does it also support onnxruntime::IExecutionProvider?

@skottmckay

Copy link
Copy Markdown
Contributor Author

does it also support onnxruntime::IExecutionProvider?

Yes. The ORT implementation deals in IExecutionProvider. If it's a plugin EP the OrtEp gets wrapped by an IExecutionProvider based class. If the IExecutionProvider's CreatePreferredAllocators returns an allocator with type or OrtReadOnlyAllocator in the SessionState ctor it will be used for initializers.

@jywu-mysoft
George Wu (jywu-mysoft) merged commit b832ca3 into main Jul 24, 2025
@jywu-mysoft
George Wu (jywu-mysoft) deleted the skottmckay/AddSupportForReadOnlyAllocatorToBeUsedWithInitializers branch July 24, 2025 15:10
Ryan Metcalfe (RyanMetcalfeInt8) pushed a commit to RyanMetcalfeInt8/onnxruntime that referenced this pull request Jul 29, 2025
### Description
<!-- Describe your changes. -->
Add new allocator type of OrtReadOnlyAllocator to enable providing a
separate allocator that is only used for initializers.

Update the SessionState logic to support this allocator type being
provided, and use it when doing device allocations for initializers.

### 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. -->
Performance.
Sanket Kale (sanketkaleoss) pushed a commit to sanketkaleoss/onnxruntime that referenced this pull request Aug 11, 2025
### Description
<!-- Describe your changes. -->
Add new allocator type of OrtReadOnlyAllocator to enable providing a
separate allocator that is only used for initializers.

Update the SessionState logic to support this allocator type being
provided, and use it when doing device allocations for initializers.

### 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. -->
Performance.
Yulong Wang (fs-eire) added a commit that referenced this pull request Aug 11, 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.
Maximilian Müller (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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants