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
【Hackathon 6th No.26】为 paddle.view 进行功能增强 -part #64205
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
#63134 之前的PR已实现 XavierNormal gain |
试了一下 感觉是支持paddle.xx这种作为输入的。另外我全局搜了一下test。似乎没搜到view 的 test。请问还需要在哪里补充一下测试用例么 |
@luotao1 @zhwesky2010 hi, 我似乎没在test里找到关于view的test。我需要为-1的shape推导单独写一个test么。如果需要我该写在什么位置呢。谢谢~(我已经测试过,并确定shape推导没问题了) |
在test_stride.py里面,在这个里面加一个case吧:https://github.com/PaddlePaddle/Paddle/blob/develop/test/deprecated/legacy_test/test_stride.py#L519-L557 |
@yinfan98 看一下PR-CI-APPROVAL 的失败原因,需要使用 np.tesing.assert 来测试 |
auto new_size = 1; | ||
auto numel = input.numel(); | ||
std::vector<int64_t> dims_copy = dims; | ||
for (int dim = 0, ndim = dims_copy.size(); dim != ndim; ++dim) { |
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.
这个不是dim<ndim吗
} | ||
} | ||
if (infer_dim >= 0 && new_size > 0 && numel % new_size == 0) { | ||
if (new_size == 0) { |
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.
这个异常在前面的 numel % new_size
不会被触发吗,应该在前面就PADDLE_ENFOCE_NEQ
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.
LGTM
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.
LGTM
在python api接口添加了代码示例,以便docs能同步更新~ |
python/paddle/tensor/manipulation.py
Outdated
|
||
>>> x = paddle.rand([2, 4, 6], dtype="float32") | ||
|
||
>>> out = paddle.view(x, paddle.uint8") |
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.
这一行代码无法运行
np.testing.assert_allclose(x.numpy(), x_np) | ||
|
||
# shape inference | ||
out = paddle.view(x, [10, 100, -1]) |
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.
可以适当增加下测试case,当前测试形状推导是4维推导3维。可以扩充到2,1维情况,或是低维到高维。
add dim4 -> dim2 add dim4 -> dim1 add dim4 -> dim5
静态检查没过,请问是因为我在view 的 api接口的注释里使用print了吗?这种情况下我需要修改哪里或者如何通过一下嘞 |
这个没有关系,最后review通过后,可以豁免 |
get~谢谢。 |
LGTM |
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.
LGTM
* support infer dims * fix error * fix error * Update view_kernel.cc * fix code format * Update test_stride.py * using np.testing.assert_allclose * fix lint * fix div0 error * using PADDLE_ENFORCE_NE * fix lint * update python api * update python api * fix view test typo * add view test add dim4 -> dim2 add dim4 -> dim1 add dim4 -> dim5 * fix lint
* support infer dims * fix error * fix error * Update view_kernel.cc * fix code format * Update test_stride.py * using np.testing.assert_allclose * fix lint * fix div0 error * using PADDLE_ENFORCE_NE * fix lint * update python api * update python api * fix view test typo * add view test add dim4 -> dim2 add dim4 -> dim1 add dim4 -> dim5 * fix lint
PR Category
Others
PR Types
Improvements
Description
增强paddle.view,使其能支持动态推理shape