Skip to content

Conversation

@ezyang
Copy link
Contributor

@ezyang ezyang commented Nov 2, 2022

Stack from ghstack (oldest at bottom):

The semantics is "as if" you did a reshape, but it always copied
even if the input was directly view'able.

Signed-off-by: Edward Z. Yang [email protected]

The semantics is "as if" you did a reshape, but it always copied
even if the input was directly view'able.

Signed-off-by: Edward Z. Yang <[email protected]>

[ghstack-poisoned]
@pytorch-bot
Copy link

pytorch-bot bot commented Nov 2, 2022

🔗 Helpful Links

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

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

❌ 1 Failures

As of commit 4c0a6a4:

The following jobs have failed:

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

- name: special_spherical_bessel_j0(Tensor x) -> Tensor
x: non_differentiable

- name: reshape_copy(Tensor self, SymInt[] size) -> Tensor
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even if I did add the kwarg, I would still have to add an extra operator, similar to how we have _to_copy

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.

Just a question about consistency with .to()
But if you need an actual different function and the flag is not enough, the PR sounds good.

@ezyang ezyang added release notes: python_frontend python frontend release notes category topic: new features topic category labels Nov 2, 2022
The semantics is "as if" you did a reshape, but it always copied
even if the input was directly view'able.

Signed-off-by: Edward Z. Yang <ezyangfb.com>

[ghstack-poisoned]
@ezyang ezyang added the ciflow/trunk Trigger trunk jobs on your pull request label Nov 2, 2022
The semantics is "as if" you did a reshape, but it always copied
even if the input was directly view'able.

Signed-off-by: Edward Z. Yang <ezyangfb.com>

[ghstack-poisoned]
TORCH_CHECK(0, "_reshape_copy not implemented for mkldnn tesnors");
}

if (self.is_contiguous()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you need this conditional, you are making a clone anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess I can always clone and then unsafe view... I suppose I was trying to avoid calling unsafe view in some situations haha

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The guts here don't really matter, the inside of this function is never traced.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Unsafe view is safe really, it does check the sizes, it just doesn't set up autograd tracking that you don't need here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I will update this

The semantics is "as if" you did a reshape, but it always copied
even if the input was directly view'able.

Signed-off-by: Edward Z. Yang <ezyangfb.com>

[ghstack-poisoned]
@ezyang
Copy link
Contributor Author

ezyang commented Nov 3, 2022

@pytorchbot merge -f "failures are spurious"

@pytorchmergebot
Copy link
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes).

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

kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Nov 5, 2022
The semantics is "as if" you did a reshape, but it always copied
even if the input was directly view'able.

Signed-off-by: Edward Z. Yang <[email protected]>
Pull Request resolved: pytorch#88314
Approved by: https://github.com/albanD
kulinseth pushed a commit to kulinseth/pytorch that referenced this pull request Dec 10, 2022
The semantics is "as if" you did a reshape, but it always copied
even if the input was directly view'able.

Signed-off-by: Edward Z. Yang <[email protected]>
Pull Request resolved: pytorch#88314
Approved by: https://github.com/albanD
@facebook-github-bot facebook-github-bot deleted the gh/ezyang/1491/head branch June 8, 2023 16:28
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: new features topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants