Repository navigation
Validate tensor slicing, sparse CSR shapes, and opset versions - #33632
Open
m00dy (professor-moody) wants to merge 1 commit into
Open
m00dy (professor-moody) wants to merge 1 commit into
m00dy (professor-moody) wants to merge 1 commit into
Conversation
## Summary Reject invalid tensor-slicer indices, overflow-prone sparse CSR shape metadata, and ONNX opset versions that cannot be represented by the runtime. Also propagate model-loading failures instead of continuing after a failed status. ## Changes - Validate the slice dimension and dimension-zero offset before creating tensor views. - Express the CSR row invariant without overflowing `rows + 1`. - Validate imported opset versions before narrowing them to `int`. - Return the model-loading status immediately on failure. - Preserve transformer coverage by removing a duplicate zero-version import from one legacy fixture in memory before that test loads the model. - Add valid and invalid slicer tests, a sparse CSR overflow-boundary test, and invalid opset version tests. ## Testing - Built the full onnxruntime_test_all target in Release mode on Linux. - Test-only baseline: 2,504 passed, 2 added regression tests failed, and 26 existing environment-dependent tests skipped. - Patched full suite: 2,506 passed and the same 26 existing tests skipped. - Pre-run and post-run hashes match within each execution, and the red and green executable hashes differ.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused validation changes have regression coverage, and no actionable issues were identified across the seven reviewed files.
No open issues 🎉
What changed in this PR
This PR strengthens ONNX Runtime’s input validation for tensor slicing, sparse CSR conversion, and model loading.
Changes:
- Reject invalid slice indices and opset versions before indexing or narrowing.
- Avoid overflow in CSR row validation and propagate model-loading failures.
- Add regression tests and normalize a legacy fixture’s invalid opset import in memory.
| File | Description |
|---|---|
onnxruntime/test/ir/onnx_model_test.cc |
Tests rejection of invalid opset versions. |
onnxruntime/test/framework/tensor_test.cc |
Adds valid and invalid tensor-slicer cases. |
onnxruntime/test/framework/sparse_kernels_test.cc |
Tests the CSR row-count overflow boundary. |
onnxruntime/test/framework/insert_cast_transformer_test.cc |
Removes an invalid duplicate import before loading the fixture. |
onnxruntime/core/graph/model.cc |
Validates opset versions and returns loading failures. |
onnxruntime/core/framework/sparse_utils.cc |
Makes the CSR row invariant overflow-safe. |
onnxruntime/core/framework/ort_value_tensor_slicer.cc |
Validates slice dimensions and dimension-zero offsets. |
Review effort: Balanced
This branch has not been deployed
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.
Summary
Reject invalid tensor-slicer indices, overflow-prone sparse CSR shape metadata, and ONNX opset versions that cannot be represented by the runtime. Also propagate model-loading failures instead of continuing after a failed status.
Changes
rows + 1.int.Testing