-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
base: develop
Are you sure you want to change the base?
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
using Type = | ||
typename std::conditional<std::is_same<T, bool>::value, int, T>::type; | ||
std::vector<Type> out_vec; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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来初始化
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
但是int和bool的字节数对不上,这里的TensorToVector不会出现问题吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
test/legacy_test/test_roll_op.py
Outdated
@@ -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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--> data_x_zero_size
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以多测试几种不同的0-size+shift+axis的组合
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
PR Category
User Experience
PR Types
Bug fixes
Description
解决了roll的输入为0size时的情况,为roll增加了bool类型支持
这个测试需要isnan支持复数,下面的pr正在做
#70126