Skip to content

Conversation

chilo-ms
Copy link
Contributor

@chilo-ms chilo-ms commented Oct 9, 2025

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.
image

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.

yuslepukhin
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants