Skip to content

Better reshape with autograd support (#82754)#84154

Closed
drisspg wants to merge 1 commit intopytorch:masterfrom
drisspg:export-D39023822
Closed

Better reshape with autograd support (#82754)#84154
drisspg wants to merge 1 commit intopytorch:masterfrom
drisspg:export-D39023822

Conversation

@drisspg
Copy link
Contributor

@drisspg drisspg commented Aug 26, 2022

The original author is @YifanShenSZ and the original PR is: #82754

Summary:

Previous reshape https://github.com/pytorch/pytorch/issues/80981 is ok for forward, but needs improvement for backward: need to handle "sometimes view sometimes copy" behavior.

This pull request fixes it by:

  1. add a new alias dispatch key CompositeImplicitAutogradNestedTensor, which ideally would work as nested-tensor version of CompositeImplicitAutograd
  2. register reshape_nested to reshape by CompositeImplicitAutogradNestedTensor

Side changes:

  • add contiguous memory format support to clone_nested
  • add view_nested
  • add reshape_as_nested

Fix issue #83041

Pull Request resolved: #82754

Test Plan:
Imported from GitHub, without a Test Plan: line.

Static Docs Preview: executorch
|Full Site|

|Modified Pages|

Reviewed By: albanD

Differential Revision: D39023822

Pulled By: drisspg

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Aug 26, 2022

🔗 Helpful links

✅ No Failures (0 Pending)

As of commit 2b2b75e (more details on the Dr. CI page):

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39023822

@drisspg drisspg requested a review from bdhirsh August 26, 2022 22:37
@drisspg drisspg added module: nestedtensor NestedTensor tag see issue #25032 release notes: nested tensor Changes that have a direct impact on nested tensors labels Aug 26, 2022
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39023822

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39023822

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39023822

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39023822

Copy link
Collaborator

@bdhirsh bdhirsh left a comment

Choose a reason for hiding this comment

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

lgtm!

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.

I want to look into the view logic in more details. But this should be ok to land for now.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39023822

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39023822

Summary:
Pull Request resolved: pytorch#84154

Previous reshape [https://github.com/pytorch/pytorch/issues/80981](https://github.com/pytorch/pytorch/pull/80981) is ok for forward, but needs improvement for backward: need to handle "sometimes view sometimes copy" behavior.

This pull request fixes it by:
1. add a new alias dispatch key `CompositeImplicitAutogradNestedTensor`, which ideally would work as nested-tensor version of `CompositeImplicitAutograd`
2. register `reshape_nested` to `reshape` by `CompositeImplicitAutogradNestedTensor`

Side changes:
* add contiguous memory format support to `clone_nested`
* add `view_nested`
* add `reshape_as_nested`

Fix issue [https://github.com/pytorch/pytorch/issues/83041](https://github.com/pytorch/pytorch/issues/83041)

Pull Request resolved: pytorch#82754

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**Static Docs Preview: executorch**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D39023822/V26/executorch/)|

|**Modified Pages**|

**Static Docs Preview: executorch**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D39023822/V17/executorch/)|

|**Modified Pages**|

Reviewed By: albanD, bdhirsh

Differential Revision: D39023822

Pulled By: drisspg

fbshipit-source-id: 87acd4f9fb61cd094fccad7801c25e2a1bfed88b
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D39023822

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge -f 'Landed internally'

(Initiating merge automatically since Phabricator Diff has merged, using force because this PR might not pass merge_rules.json but landed internally)

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge job. Check the current status here.
The merge job was triggered with the force (-f) flag. This means your change will be merged immediately, bypassing any CI checks (ETA: 1-5 minutes). If this is not the intended behavior, feel free to use some of the other merge options in the wiki.
Please reach out to the PyTorch DevX Team with feedback or questions!

facebook-github-bot pushed a commit that referenced this pull request Sep 1, 2022
Summary:
Pull Request resolved: #84154

Previous reshape [https://github.com/pytorch/pytorch/issues/80981](https://github.com/pytorch/pytorch/pull/80981) is ok for forward, but needs improvement for backward: need to handle "sometimes view sometimes copy" behavior.

This pull request fixes it by:
1. add a new alias dispatch key `CompositeImplicitAutogradNestedTensor`, which ideally would work as nested-tensor version of `CompositeImplicitAutograd`
2. register `reshape_nested` to `reshape` by `CompositeImplicitAutogradNestedTensor`

Side changes:
* add contiguous memory format support to `clone_nested`
* add `view_nested`
* add `reshape_as_nested`

Fix issue [https://github.com/pytorch/pytorch/issues/83041](https://github.com/pytorch/pytorch/issues/83041)

Pull Request resolved: #82754

Test Plan:
Imported from GitHub, without a `Test Plan:` line.

**Static Docs Preview: executorch**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D39023822/V27/executorch/)|

|**Modified Pages**|

**Static Docs Preview: executorch**
|[Full Site](https://our.intern.facebook.com/intern/staticdocs/eph/D39023822/V17/executorch/)|

|**Modified Pages**|

Reviewed By: albanD, bdhirsh

Differential Revision: D39023822

Pulled By: drisspg

fbshipit-source-id: 872c81dc847d280366ef9f187f9b9bcb06aac73f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed fb-exported Merged module: nestedtensor NestedTensor tag see issue #25032 release notes: nested tensor Changes that have a direct impact on nested tensors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants