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

【HEU】[Paddle Tensor 第二期 API鲁棒性增强] paddle.roll 支持 0-size tensor 与 bool #70537

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

fangfangssj
Copy link
Contributor

PR Category

User Experience

PR Types

Bug fixes

Description

解决了roll的输入为0size时的情况,为roll增加了bool类型支持
d42489a6a9fb007dfe55fb9f997a4131
这个测试需要isnan支持复数,下面的pr正在做
#70126

Copy link

paddle-bot bot commented Dec 29, 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 29, 2024
@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Dec 30, 2024
Comment on lines 30 to 32
using Type =
typename std::conditional<std::is_same<T, bool>::value, int, T>::type;
std::vector<Type> out_vec;
Copy link
Contributor

Choose a reason for hiding this comment

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

为什么当T是bool时,out_vec的类型是int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

下面的代码中有一个out_vec.data()的调用,但是bool类型的vertor没有这个实现,所以将对应bool类型的实现使用了int来初始化

Copy link
Contributor

Choose a reason for hiding this comment

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

但是int和bool的字节数对不上,这里的TensorToVector不会出现问题吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@@ -185,6 +185,7 @@ def input_data(self):
self.data_x = np.array(
[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 9.0]]
)
self.data_zero_x = np.array([]).reshape(0, 3).astype('float32')
Copy link
Contributor

Choose a reason for hiding this comment

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

--> data_x_zero_size

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

with paddle.static.program_guard(
paddle.static.Program(), paddle.static.Program()
):
x = paddle.static.data(name='x', shape=[0, 3], dtype='float32')
Copy link
Contributor

Choose a reason for hiding this comment

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

可以多测试几种不同的0-size+shift+axis的组合

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

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