Skip to content

Conversation

wodesuck
Copy link
Contributor

Similar with #2578, for this case:

import torch
import torch.nn as nn


class Model(nn.Module):
    def forward(self, x):
        return x.new_zeros(x.shape)


def main():
    model = Model()
    args = torch.rand(4, 4),
    batch = torch.export.Dim("batch")
    dynamic_shapes = {"x": {0: batch}}
    torch.onnx.export(
        model,
        args,
        "model_test.onnx",
        dynamic_shapes=dynamic_shapes,
        dynamo=True,
    )


if __name__ == "__main__":
    main()

Copy link
Collaborator

@justinchuby justinchuby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@justinchuby justinchuby enabled auto-merge (squash) September 30, 2025 14:08
Copy link

codecov bot commented Sep 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.08%. Comparing base (3a26097) to head (0689a47).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2588      +/-   ##
==========================================
+ Coverage   70.07%   70.08%   +0.01%     
==========================================
  Files         223      223              
  Lines       26263    26266       +3     
  Branches     2600     2601       +1     
==========================================
+ Hits        18404    18409       +5     
+ Misses       6948     6947       -1     
+ Partials      911      910       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@justinchuby
Copy link
Collaborator

Should this be added for other ops, eg. CastLike, Abs, etc. ? Essentially whenever the output is a known PyTorch value that has complete shape, and when the input has dynamic dims that the onnx shape inference engine doesn’t yet handle.

@gramalingam

@gramalingam
Copy link
Collaborator

Should this be added for other ops, eg. CastLike, Abs, etc. ?

All those simplifications rewrite it to Identity(...), so this should automatically work there?

@justinchuby
Copy link
Collaborator

justinchuby commented Sep 30, 2025

I don't understand why in the test test_static_split_to_sequence_with_uneven_split_proto we see a value with shape but no dtype information. Nevertheless I created onnx/ir-py#203

Set input type to output type if input type is None.
@justinchuby
Copy link
Collaborator

Turns out we should relay the type as well

@justinchuby justinchuby reopened this Sep 30, 2025
@justinchuby justinchuby added this to the 0.5.3 milestone Sep 30, 2025
@justinchuby justinchuby enabled auto-merge (squash) September 30, 2025 19:46
@justinchuby justinchuby merged commit 7227655 into microsoft:main Sep 30, 2025
46 of 59 checks passed
justinchuby added a commit to onnx/ir-py that referenced this pull request Oct 1, 2025
Following microsoft/onnxscript#2588. Handle shape info as well.

Signed-off-by: Justin Chu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants