-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add partial data propagation to enhance shape inference #26269
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
Open
chilo-ms
wants to merge
21
commits into
main
Choose a base branch
from
chi/fix_shape_inference
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
…ta propagation to work correctly
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes.py
Fixed
Show fixed
Hide fixed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes_v2.py
Fixed
Show fixed
Hide fixed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes.py
Fixed
Show fixed
Hide fixed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes.py
Fixed
Show fixed
Hide fixed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes.py
Fixed
Show fixed
Hide fixed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes_v2.py
Fixed
Show fixed
Hide fixed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes_v2.py
Fixed
Show fixed
Hide fixed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes_v2.py
Fixed
Show fixed
Hide fixed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes.py
Dismissed
Show dismissed
Hide dismissed
onnxruntime/test/testdata/test_shape_data_propagation_with_shape_related_nodes_v2.py
Dismissed
Show dismissed
Hide dismissed
yuslepukhin
requested changes
Oct 14, 2025
yuslepukhin
reviewed
Oct 14, 2025
yuslepukhin
reviewed
Oct 14, 2025
yuslepukhin
previously approved these changes
Oct 14, 2025
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
Calling an operator's
TypeAndShapeInferenceFunction()
alone is sometimes insufficient for complete shape inference.For example, the
Shape
operator only infers the output’s rank (a 1-dimensional tensor) but not its actual dimension values.For instance, given an input of shape [1, 3, 64, 64], the Shape operator's
TypeAndShapeInferenceFunction()
produces an output shape tensor with 1-dimension as int64[4], representing the rank of the input tensor.Therefore, as you can imagine, the below graph's output shape can't be properly inferred (even though the input shape is known) because the shape data is lost at the

Shape
operator.To solve the issue, the
PartialDataPropagationFunction()
, defined in the ONNX operator schema, must also be executed to obtain the concrete output shape values, allowing accurate propagation of shape information throughout the graph.This PR adds the support of executing operator's
PartialDataPropagationFunction()
in ORT, and makes sure the shape values is properly propagated throughout the graph.Motivation and Context
When using the Compile API to generate an EPContext model, all graph optimizations are disabled by default except for free dimension overrides. However, for certain models, such as a VAE decoder, the output shape may still fail to be properly inferred even when free dimension override values are provided beforehand.
However, you won't hit this issue if enabling all the graph optimizations as some nodes, e.g.
Shape
,Reshape
.. will be constant folded.