Skip to content

Add API GetTensorElementTypeAndShapeDataReference#27175

Merged
adrianlizarraga merged 7 commits intomainfrom
adrianl/Api_OrtValueGetTensorShapeTypeNoAlloc
Jan 28, 2026
Merged

Add API GetTensorElementTypeAndShapeDataReference#27175
adrianlizarraga merged 7 commits intomainfrom
adrianl/Api_OrtValueGetTensorShapeTypeNoAlloc

Conversation

@adrianlizarraga
Copy link
Copy Markdown
Contributor

@adrianlizarraga adrianlizarraga commented Jan 27, 2026

Description

Adds C/C++ API named GetTensorElementTypeAndShapeDataReference that returns an OrtValue tensor's shape and type without allocating a new buffer for the shape data.

Motivation and Context

This new API function can be used instead of OrtApi::GetTypeInfo() or OrtApi::GetTensorTypeAndShape to decrease the number of heap allocations and thus improve inference latency for plugin EPs kernels that frequently retrieve tensor shapes during inference. (e.g., WebGPU plugin EP)

@adrianlizarraga adrianlizarraga changed the title Adrianl/api ort value get tensor shape type no alloc [DRAFT] Add API Value_GetTensorElementTypeAndShape (returns shape data without copy) Jan 27, 2026
@adrianlizarraga adrianlizarraga changed the title [DRAFT] Add API Value_GetTensorElementTypeAndShape (returns shape data without copy) Add API Value_GetTensorElementTypeAndShape (returns shape data without copy) Jan 28, 2026
@adrianlizarraga adrianlizarraga marked this pull request as ready for review January 28, 2026 18:03
@adrianlizarraga adrianlizarraga changed the title Add API Value_GetTensorElementTypeAndShape (returns shape data without copy) Add API GetTensorElementTypeAndShapeDataReference Jan 28, 2026
edgchen1
edgchen1 previously approved these changes Jan 28, 2026
@adrianlizarraga adrianlizarraga enabled auto-merge (squash) January 28, 2026 22:15
@adrianlizarraga adrianlizarraga merged commit 0f153de into main Jan 28, 2026
89 of 91 checks passed
@adrianlizarraga adrianlizarraga deleted the adrianl/Api_OrtValueGetTensorShapeTypeNoAlloc branch January 28, 2026 22:54
tianleiwu pushed a commit that referenced this pull request Jan 29, 2026
Adds C/C++ API named `GetTensorElementTypeAndShapeDataReference` that
returns an OrtValue tensor's shape and type without allocating a new
buffer for the shape data.
This new API function can be used instead of `OrtApi::GetTypeInfo()` or
`OrtApi::GetTensorTypeAndShape` to decrease the number of heap
allocations and thus improve inference latency for plugin EPs kernels
that frequently retrieve tensor shapes during inference. (e.g., WebGPU
plugin EP)
tianleiwu added a commit that referenced this pull request Jan 29, 2026
| Commit | Commit Title | Author |
| :--- | :--- | :--- |
| `6861526` | [MLAS] Fix Data Race in MlasLutGemm by Serializing LUT
Generation (#27179) | tianleiwu |
| `592bcb4` | remove coloredlogs (#27135) | tianleiwu |
| `0f153de` | Add API GetTensorElementTypeAndShapeDataReference (#27175)
| adrianlizarraga |
| `1caa3e6` | [MLAS] Fix Flaky LuT GEMM Tests by Replacing Gather with
Shuffle (#27174) | tianleiwu |

---------

Co-authored-by: Adrian Lizarraga <adlizarraga@microsoft.com>
milpuz01 pushed a commit to milpuz01/onnxruntime that referenced this pull request Feb 4, 2026
### Description
Adds C/C++ API named `GetTensorElementTypeAndShapeDataReference` that
returns an OrtValue tensor's shape and type without allocating a new
buffer for the shape data.



### Motivation and Context
This new API function can be used instead of `OrtApi::GetTypeInfo()` or
`OrtApi::GetTensorTypeAndShape` to decrease the number of heap
allocations and thus improve inference latency for plugin EPs kernels
that frequently retrieve tensor shapes during inference. (e.g., WebGPU
plugin EP)
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