Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Semi-Auto] Add reshape infer_backward rule #56443

Merged
merged 1 commit into from Sep 8, 2023

Conversation

pkuzyc
Copy link
Contributor

@pkuzyc pkuzyc commented Aug 18, 2023

PR types

New features

PR changes

Others

Description

Pcard-70448

Add infer backward SPMD rule for reshape. It infers inputs' dims mappings as following:

  1. Get transformation from output shape to input.
  2. Infer input's dims mapping according to the transformation.

@paddle-bot
Copy link

paddle-bot bot commented Aug 18, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented Aug 26, 2023

Sorry to inform you that 6e45db7's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@@ -248,6 +248,171 @@ def test_reshape_infer_forward(self):
with self.assertRaises(BaseException):
self.rule.infer_forward([self.x_dist_tensor_spec], self.attrs)

def test_reshape_infer_backward(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

unitest lack some cases where the axis of output is shard and need to be recover to unsharded before reshard:

case1: last axis of output
shape: [6, 12, 48, 24] --> [1, 72, 48, 4, 6] (input --> output)
dims_mapping: [-1, 0, -1, -1, 1] --> [0, -1, -1, -1], [-1, 0, 1, -1, -1] (output --> input, output)

case2: 2nd axis of output
shape: [6, 12, 48, 24] --> [3, 24, 6, 8, 24] (input --> output)
dims_mapping: [-1, 1, -1, -1, 0] --> [-1, -1, -1, 0], [-1, -1, -1, -1, 0] (output --> input, output)

Copy link
Contributor

@JZ-LIANG JZ-LIANG left a comment

Choose a reason for hiding this comment

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

Update in next PR

@JZ-LIANG JZ-LIANG merged commit 8e9de87 into PaddlePaddle:develop Sep 8, 2023
25 of 26 checks passed
BeingGod pushed a commit to BeingGod/Paddle that referenced this pull request Sep 9, 2023
@pkuzyc pkuzyc deleted the reshape_backward branch September 27, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants