Skip to content

Conversation

MRADULTRIPATHI
Copy link

Fixes #2533

What & Why

  • aten::unbind.int should match PyTorch’s torch.unbind, which removes the unbound axis.
  • Previous implementation produced (3,1) instead of (3,), causing shape mismatches.

Changes

  • Implemented aten::unbind.int using opset18 SplitToSequence with keepdims=False.
  • Ensures output shapes match PyTorch semantics correctly.
  • Cleaned up decorator to use the correct naming format: aten::unbind.int.

Tests

  • Added eager-mode test (test_unbind_matches_torch) to compare shapes vs PyTorch.
  • Verified locally with:
    pytest docs/test/test_documentation_examples.py -v -k "test_unbind_matches_torch"

@MRADULTRIPATHI
Copy link
Author

MRADULTRIPATHI commented Sep 2, 2025

Hi @microsoft/onnxscript- @maintainers

I’ve submitted this PR to fix issue #2533 (aten::unbind.int conversion mismatch).

  • Updated implementation to use SplitToSequence(..., keepdims=False) from opset18
    so that the unbound axis is removed correctly, matching PyTorch’s torch.unbind.
  • Added an eager-mode test to compare shapes against PyTorch.
  • Verified locally with:
    pytest docs/test/test_documentation_examples.py -v -k "test_unbind_matches_torch"
    ✅ Passed successfully.

Kindly review this PR when you get a chance. Thanks a lot for your time and guidance

Copy link

codecov bot commented Sep 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.02%. Comparing base (07f3e4c) to head (23afd6d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2534      +/-   ##
==========================================
+ Coverage   70.00%   70.02%   +0.01%     
==========================================
  Files         215      215              
  Lines       25992    25992              
  Branches     2606     2606              
==========================================
+ Hits        18196    18201       +5     
+ Misses       6896     6891       -5     
  Partials      900      900              

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

@MRADULTRIPATHI
Copy link
Author

Hi @justinchuby @linshokaku,
I’ve updated the implementation and fixed all lint issues for aten::unbind.int.

All local tests are passing ✅
Could you please approve and trigger the workflows so that the CI checks can run?
Thanks a lot for your time and review

test("..", "..", "docs", "tutorial", "rewriter", "examples")


def test_unbind_matches_torch():
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think this is the right place for the test. Please move to test_models_e2e and follow the format there

Copy link
Author

@MRADULTRIPATHI MRADULTRIPATHI Sep 2, 2025

Choose a reason for hiding this comment

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

All local lint/style/tests are passing ✅ and CI checks are currently running.

Please let me know if you’d prefer me to wait until all checks finish,
or if I should go ahead and make all the requested changes right away.
I’ll be happy to update accordingly. 🙂

Copy link
Author

Choose a reason for hiding this comment

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

@justinchuby please reply what should i do?

Copy link
Author

Choose a reason for hiding this comment

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

Hi @justinchuby, I noticed that test_models_e2e currently contains model-level tests like mobilenetv2_100 and resnet18.
Since my test validates correctness of a single op (unbind) against PyTorch rather than a model, could you please clarify where exactly I should move it?

  • Should I create a new file under unittest_models (since it’s op-level)?
  • Or should I still place it under test_models_e2e in a new file dedicated for small op-level checks?

I want to make sure the test is placed in the right location and aligned with the project’s organization before I proceed with the changes. Thanks!
Screenshot 2025-09-03 004100

Matches the behavior of torch.unbind.
"""
split_size = op.Constant(value_int=1)
return op.SplitToSequence(self, split_size, axis=dim, keepdims=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What excetly was updated?

Copy link
Author

Choose a reason for hiding this comment

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

The update in core.py ensures that aten::unbind.int matches PyTorch’s torch.unbind behavior. Previously, the implementation returned tensors with an extra dimension (e.g., (3,1)), but with SplitToSequence(..., keepdims=False), it now correctly returns (3,) which aligns with PyTorch

@justinchuby
Copy link
Collaborator

If you are using an ai to assist with the change, please list the tools used. For now I think #2536 should fix it. Thanks!

@MRADULTRIPATHI
Copy link
Author

MRADULTRIPATHI commented Sep 2, 2025

If you are using an ai to assist with the change, please list the tools used. For now I think #2536 should fix it. Thanks!

For transparency: I used GitHub Copilot/ChatGPT to assist in drafting the initial implementation and test. I manually reviewed, verified the changes, fixed style/lint issues, and ran the tests locally to ensure correctness before submitting @justinchuby

@justinchuby
Copy link
Collaborator

Hi @MRADULTRIPATHI I think #2536 will fix the issue. I recommend heading over to https://github.com/microsoft/onnxscript/issues?q=sort%3Aupdated-desc%20is%3Aissue%20is%3Aopen%20label%3A%22contribution%20welcome%22&page=2 to see if there are other issues you find interesting. Thanks!

@MRADULTRIPATHI
Copy link
Author

MRADULTRIPATHI commented Sep 2, 2025

Got it, thanks for clarifying! I’ll look into the open issues labeled "contribution welcome" and see where I can help contribute further. Appreciate the guidance @justinchuby Just to confirm — should I wait here for any further action, or go ahead and close this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Conversion mismatch for aten::unbind.int
2 participants