Accept legacy WebGPU/WebNN memory info names for backward compatibility#27637
Merged
Accept legacy WebGPU/WebNN memory info names for backward compatibility#27637
Conversation
Accept pre-1.25 names "WebGPU_Buffer"/"WebNN_Tensor" as aliases in CreateMemoryInfo and normalize them to the current short names "WebGPU_Buf"/"WebNN_Ten". This allows released onnxruntime-genai (which still uses the old long names) to work with main branch ORT. The normalization is critical because downstream code (external data loader, WebGPU context) compares memory info names against the current constants. Without normalization, those comparisons would fail. See: #27207 See: #27475 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
guschmue
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Accept pre-1.25 names
"WebGPU_Buffer"/"WebNN_Tensor"as aliases inCreateMemoryInfoand normalize them to the current short names"WebGPU_Buf"/"WebNN_Ten".This is the reverse of #27475 (which added forward compatibility in the 1.24.x patch branch).
Motivation and Context
Released onnxruntime-genai still uses the old (pre-1.25) long names when calling
CreateMemoryInfo. Without this change, those calls fail withORT_INVALID_ARGUMENTon main branch.Key Design Decision
When an old name is detected, it is normalized to the current short constant (e.g.,
"WebGPU_Buffer"->"WebGPU_Buf"). This is critical because downstream code (e.g.,external_data_loader.cc,webgpu_context.cc) comparesOrtMemoryInfo.nameagainst the current constants. Simply passing through the old name would cause those comparisons to fail.Changes
onnxruntime/core/framework/allocator.cc: Accept and normalize legacy names inCreateMemoryInfoonnxruntime/test/shared_lib/test_allocator.cc: Add test verifying legacy names are accepted and normalizedSee Also