KEMBAR78
Fix `torch.[size|stride]`(dim=None)` invocation by malfet · Pull Request #111991 · pytorch/pytorch · GitHub
Skip to content

Conversation

@malfet
Copy link
Contributor

@malfet malfet commented Oct 25, 2023

Per documentation, one should be able to explicitly pass dim argument as None to get tensor size across all dimentions/strides, but before this change it was incorrectly interpreted as named tensor call.

Modify size and stride signatures generated by gen_pyi.py to highlight that overload with None will return a Tuple, but one with dim: _int returns int.

Add regression test to validate the behavior, and remove the check for asserts from two named tensors tests (NamedTensors are dead, aren't they?)

Fixes #111944

Per documentation, one should be able to explicitly pass dim argument as None to get tensor size across all dimentions/strides, but before this change it was incorrectly interpreted as named tensor call

Add regression test to validate the behavior

Fixes #111944
@pytorch-bot
Copy link

pytorch-bot bot commented Oct 25, 2023

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/111991

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit df7888e with merge base a887ad0 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@malfet malfet added release notes: python_frontend python frontend release notes category topic: bug fixes topic category labels Oct 25, 2023
@malfet malfet requested a review from cpuhrsch October 25, 2023 17:03
@cpuhrsch cpuhrsch requested a review from zou3519 October 25, 2023 17:08
@@ -0,0 +1,17 @@
# Owner(s): ["module: tests"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I would put this into test/test_torch.py, that is where a lot of our basic tensor tests go

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would agree that a test_misc is not very descriptive. Also no team is signed up to look at module: tests so I think we should avoid using it here as much as possible.

Copy link
Contributor Author

@malfet malfet Oct 25, 2023

Choose a reason for hiding this comment

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

Drumroll (this is where I got the idea in the first place):

# Owner(s): ["module: tests"]

But sure, can move it to test_torch.py

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

nit on the test file name. but SGTM otherwise

@@ -0,0 +1,17 @@
# Owner(s): ["module: tests"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would agree that a test_misc is not very descriptive. Also no team is signed up to look at module: tests so I think we should avoid using it here as much as possible.

@malfet malfet added the topic: bc breaking topic category label Oct 25, 2023
@malfet
Copy link
Contributor Author

malfet commented Oct 25, 2023

@pytorchbot merge

@pytorch-bot pytorch-bot bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 25, 2023
@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot
Copy link
Collaborator

Merge failed

Reason: 1 mandatory check(s) failed. The first few are:

Dig deeper by viewing the failures on hud

Details for Dev Infra team Raised by workflow job

Failing merge rule: Core Maintainers

@malfet
Copy link
Contributor Author

malfet commented Oct 26, 2023

@pytorchbot merge

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

xuhancn pushed a commit to xuhancn/pytorch that referenced this pull request Nov 7, 2023
Per documentation, one should be able to explicitly pass dim argument as None to get tensor size across all dimentions/strides, but before this change it was incorrectly interpreted as named tensor call.

Modify `size` and `stride` signatures generated by `gen_pyi.py` to highlight that overload with `None` will return a Tuple, but one with `dim: _int` returns `int`.

Add regression test to validate the behavior, and remove the check for asserts from two named tensors tests (NamedTensors are dead, aren't they?)

Fixes pytorch#111944
Pull Request resolved: pytorch#111991
Approved by: https://github.com/zou3519
Skylion007 pushed a commit to Skylion007/pytorch that referenced this pull request Nov 14, 2023
Per documentation, one should be able to explicitly pass dim argument as None to get tensor size across all dimentions/strides, but before this change it was incorrectly interpreted as named tensor call.

Modify `size` and `stride` signatures generated by `gen_pyi.py` to highlight that overload with `None` will return a Tuple, but one with `dim: _int` returns `int`.

Add regression test to validate the behavior, and remove the check for asserts from two named tensors tests (NamedTensors are dead, aren't they?)

Fixes pytorch#111944
Pull Request resolved: pytorch#111991
Approved by: https://github.com/zou3519
@malfet malfet deleted the malfet/fix-size-stride-invocation branch November 30, 2023 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged release notes: python_frontend python frontend release notes category topic: bc breaking topic category topic: bug fixes topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

torch.tensor.size(dim=None) fails, expects dim to be a "name"

4 participants