Skip to content

【BUPT】[Paddle Tensor 第二期 API 支持 0-size Tensor] paddle.unstack 支持 0-size tensor #70342

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

Merged
merged 4 commits into from
Dec 26, 2024

Conversation

nizne9
Copy link
Contributor

@nizne9 nizne9 commented Dec 19, 2024

PR Category

User Experience

PR Types

Bug fixes

Description

  1. paddle.unstack 提供 0-size tensor 输入的支持
  2. 编写 0-size tensor 输入下的测试。因为 numpy 在 v2.1.0 才支持 numpy.unstack,测试里使用的是与其等效的 tuple(np.moveaxis(x, axis, 0))
    jietu-1734592319279

Copy link

paddle-bot bot commented Dec 19, 2024

你的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-bot paddle-bot bot added the contributor External developers label Dec 19, 2024
Comment on lines 44 to 45
auto x_grad_dim = (outs)[i]->dims();
(outs)[i]->Resize(x_grad_dim);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
auto x_grad_dim = (outs)[i]->dims();
(outs)[i]->Resize(x_grad_dim);
(outs)[i]->Resize((outs)[i]->dims());

self._test_unstack_with_shapes((0, 11, 22), axis=-2)

def _test_unstack_with_static_empty_tensor_input(self, place):
paddle.enable_static()
Copy link
Contributor

Choose a reason for hiding this comment

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

静态图和动态图的模式切换使用with dygraph_guard()和with static_guard():,代替enable/disable_static

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Dec 19, 2024
HydrogenSulfate

This comment was marked as duplicate.

Copy link
Contributor

@HydrogenSulfate HydrogenSulfate left a comment

Choose a reason for hiding this comment

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

LGTM

@HydrogenSulfate HydrogenSulfate merged commit a1f32ac into PaddlePaddle:develop Dec 26, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants