Add model-ingestion error-path tests for InferenceSession#29558
Open
GopalakrishnanN wants to merge 2 commits into
Open
Add model-ingestion error-path tests for InferenceSession#29558GopalakrishnanN wants to merge 2 commits into
GopalakrishnanN wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends ONNX Runtime’s InferenceSession negative/error-path test coverage around model ingestion, ensuring common misuse/malformed-model scenarios are rejected cleanly.
Changes:
- Adds a test that a second
Load()call on the sameInferenceSessionis rejected. - Adds a test that loading/initializing a malformed ONNX model (node consumes an undefined input) fails gracefully.
Two tests: double-Load rejection ('already contains a loaded model') and invalid-graph rejection (a node consuming an undefined input, built via ONNX proto, rejected at Load/Initialize). Verified passing against a local Release build.
GopalakrishnanN
force-pushed
the
GopalakrishnanN/more-error-path-tests
branch
from
July 10, 2026 17:23
65108e8 to
c10bb09
Compare
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.
Description
Extends error-path / negative test coverage for
InferenceSessionmodel ingestion (continuation of the audit's "thin error-path coverage" finding). Adds two tests toinference_session_test.cc:LoadModelTwiceReturnsError— a secondLoad()on a session that already holds a model must be rejected withMODEL_LOADED("This session already contains a loaded model").LoadInvalidGraphReturnsError— a model whose only node consumes an input that is never defined (not a graph input, initializer, or another node's output) is constructed via the ONNX proto API, serialized, and loaded. GraphResolvemust reject it gracefully (error atLoadorInitialize) rather than crash or silently accept it.Motivation and Context
Failure/validation paths are under-tested relative to the numeric happy-path bulk. These cover the double-load guard and the graph-resolve rejection path for a malformed graph.
Verification
Built
onnxruntime_test_all(Release, CPU) and ran both tests locally — both pass: