Skip to content

Canonicalize external data locations - #32135

Merged
Akshay Sonawane (apsonawane) merged 2 commits into
mainfrom
fix/external-data-location-canonicalization
Aug 20, 2026
Merged

Canonicalize external data locations#32135
Akshay Sonawane (apsonawane) merged 2 commits into
mainfrom
fix/external-data-location-canonicalization

Conversation

@apsonawane

Copy link
Copy Markdown
Contributor

This pull request improves the robustness and correctness of handling external data references in ONNX Runtime, particularly focusing on rejecting invalid or ambiguous "location" entries and ensuring in-memory reference tags are not treated as file paths. The changes also enhance path validation logic and add new unit tests to cover these scenarios.

Validation and error handling improvements:

  • Added a check in ExternalDataInfo::Create to reject duplicate "location" entries in the external data info, ensuring only one "location" is allowed per tensor. [1] [2]
  • Updated path validation logic in ValidateExternalDataPathFromDir and ValidateExternalDataPath to explicitly reject in-memory reference tags (used for internal memory mapping) as invalid file paths, alongside empty and absolute paths. [1] [2] [3] [4] [5] [6]

Functionality and code clarity:

  • Refined HasExternalDataInMemory to correctly detect in-memory references even if there are multiple "location" entries, improving reliability.

Testing enhancements:

  • Added new unit tests to verify that duplicate "location" entries are rejected and that in-memory reference tags are correctly handled and rejected by validation logic. [1] [2]

These changes collectively strengthen the validation of external data references, prevent ambiguous or invalid configurations, and ensure that in-memory tags are never misinterpreted as file paths.

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

Strengthens external tensor-data handling by rejecting ambiguous locations and preventing internal memory tags from being interpreted as file paths.

Changes:

  • Rejects duplicate or empty external-data locations.
  • Detects memory tags across all location entries.
  • Adds path-validation and parsing tests.

Reviewed changes

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

File Description
onnxruntime/core/framework/tensor_external_data_info.cc Validates location uniqueness and non-emptiness.
onnxruntime/core/framework/tensorprotoutils.cc Improves memory-tag detection and path rejection.
onnxruntime/test/framework/tensorutils_test.cc Covers duplicate locations and memory-tag validation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@apsonawane
Akshay Sonawane (apsonawane) merged commit d3b86e7 into main Aug 20, 2026
87 checks passed
@apsonawane
Akshay Sonawane (apsonawane) deleted the fix/external-data-location-canonicalization branch August 20, 2026 17:53
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