Relax CompileModel validation to accept zero-input OrtModel graphs - #28771
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR relaxes OrtApi::CompileModel validation for OrtModel inputs so that models with zero graph inputs are accepted, aligning CompileModel behavior with CreateSessionFromModel for input-less generator graphs (e.g., RandomNormal).
Changes:
- Update
ModelCompilationOptions::Check()to require at least one graph output, no longer requiring at least one input. - Restructure shared-lib tests to isolate the “no outputs” failure case.
- Add a regression test that compiles a 0-input, 1-output model built via the Model Editor API and asserts compilation produces a non-empty artifact.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| onnxruntime/test/shared_lib/test_model_builder_api.cc | Updates validation tests and adds a regression test covering successful compilation of a 0-input OrtModel. |
| onnxruntime/core/session/model_compilation_options.cc | Relaxes OrtModel compile-time validation to allow zero graph inputs while still requiring at least one output. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Xavier Dupré (xadupre)
approved these changes
Jun 4, 2026
Contributor
|
Nice, thanks adrastogi. |
adrastogi
pushed a commit
that referenced
this pull request
Jul 23, 2026
### Description <!-- Describe your changes. --> Set `min_arity` of inputs to zero in EPContext node registration. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> PR #28771 relaxed CompileModel validation to accept zero-input OrtModel graphs, so EpContext node should also accept zero-input.
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
Relax the input-validation in OrtApi::CompileModel to accept OrtModel instances with zero graph inputs. Previously, ModelCompilationOptions::Check() rejected such models with "OrtModel graph must have at least one input and one output defined." The check now requires only at least one graph output; the zero-input case is legal.
Tests in test_model_builder_api.cc are restructured:
Motivation and Context
Fixes #28135
The original check was too restrictive and impacts callers (e.g., WebNN/Chromium needs to call CompileModel on such models in a separate compiler process (and then load the compiled artifact via CreateSessionFromArray in the GPU process)).