Skip to content

perftest: Use plugin EP device allocators for input/output buffers - #32244

Open
Jaskaran Singh Nagi (jnagi-intel) wants to merge 2 commits into
microsoft:mainfrom
jnagi-intel:plugin-ep-allocators
Open

perftest: Use plugin EP device allocators for input/output buffers#32244
Jaskaran Singh Nagi (jnagi-intel) wants to merge 2 commits into
microsoft:mainfrom
jnagi-intel:plugin-ep-allocators

Conversation

@jnagi-intel

@jnagi-intel Jaskaran Singh Nagi (jnagi-intel) commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description

Adds support for using a plugin EP device's own allocator for input/output buffers in onnxruntime_perf_test, instead of always using the CPU allocator.

  • When a session uses plugin EP(s) (--plugin_eps), onnxruntime_perf_test now selects an allocator from the appended OrtEpDevice: it prefers the device's default (device-only) allocator, falls back to its host-accessible allocator, and falls back to the CPU allocator if neither is available or if more than one EP device was appended (no single unambiguous allocator to pick).
  • Generated inputs (-r) and pre-allocated fixed-shape outputs now use this allocator instead of the CPU allocator.
  • Real test data loaded from files is staged into the selected allocator's memory once at load time (via Ort::Env::CopyTensor), instead of being copied per-Run() implicitly.
  • String tensors are always kept in CPU-accessible memory (inputs and outputs), since std::string is placement-constructed by ORT directly into the tensor's owned memory and can't safely live in device-only memory.
  • Added [Plugin EP]-prefixed logging indicating which allocator was selected.

Motivation and Context

onnxruntime_perf_test previously always allocated input/output buffers on the CPU when running with plugin EPs. For plugin EPs whose kernels expect device-resident inputs/outputs, this meant every Run() iteration paid for an implicit host↔device copy that was entirely avoidable, skewing per-iteration latency measurements away from the EP's actual compute cost. Selecting and reusing the EP device's own allocator up front lets perf numbers better reflect steady-state inference cost for plugin EPs.

Copilot AI balanced review requested due to automatic review settings August 24, 2026 20:53
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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

Updates perftest to select allocators exposed by plugin EP devices.

Changes:

  • Returns selected plugin EP devices during session setup.
  • Chooses a default or host-accessible plugin allocator.
  • Falls back to the CPU allocator for ambiguous/unavailable devices.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
onnxruntime/test/perftest/utils.h Declares plugin device and allocator-selection APIs.
onnxruntime/test/perftest/common_utils.cc Implements selected-device tracking and allocator lookup.
onnxruntime/test/perftest/ort_test_session.cc Applies the selected allocator to perftest buffers.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread onnxruntime/test/perftest/ort_test_session.cc Outdated

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comment thread onnxruntime/test/perftest/ort_test_session.cc Outdated
Comment thread onnxruntime/test/perftest/ort_test_session.cc
Comment thread onnxruntime/test/perftest/ort_test_session.cc

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

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment on lines +1018 to +1019
if (is_dynamic || (device_memory_name_.empty() && !has_plugin_ep_allocator_) ||
(requires_input_staging_ && is_string_output)) {
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.

2 participants