Skip to content

[WIP] [tracking] Improve Sequence operator handling #25066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 14, 2025

Analyzing sequence operator handling efficiency improvements in ONNX Runtime

Overview: The current sequence operator implementation relies heavily on tensor copies as noted in the TODO comment. This PR aims to improve efficiency by reducing unnecessary tensor copying through better use of move semantics and avoiding redundant allocations.

Plan:

  • Analyze current sequence operator implementation and identify inefficiencies
  • Understand the current test structure and codebase organization
  • Optimize SequenceInsert to reduce tensor copying where possible
  • Optimize SequenceConstruct to use move semantics when appropriate
  • Add CreateTensorOrtValue function to enable direct OrtValue creation with move semantics
  • Create performance benchmark tests to measure current copying overhead
  • Investigate SequenceAt optimization opportunities (limited due to operational requirements)
  • Run existing tests to ensure no regression
  • Validate performance improvements with benchmarks

Key optimizations implemented:

  • Added CreateTensorOrtValue() function that creates OrtValue directly with move semantics instead of creating Tensor first then converting
  • Updated SequenceInsert and SequenceConstruct to use the optimized function
  • This reduces the number of copy operations and temporary object creation
  • Maintains compatibility with DataTransferManager for cross-EP support

Note: SequenceErase is already well-optimized as it avoids copying non-erased tensors. SequenceAt requires copying due to operational requirements but uses efficient DataTransferManager.

Fixes #18355.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: justinchuby <11205048+justinchuby@users.noreply.github.com>
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.

[tracking] Improve Sequence operator handling
2 participants