CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
【BUPT】[Paddle Tensor 第二期 API 支持 0-size Tensor] paddle.meshgrid 支持 0-size tensor #70127
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
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
PADDLE_ENFORCE_EQ( | ||
ins.size() > 1, | ||
true, | ||
common::errors::InvalidArgument( | ||
"Expected at least 2 input tensors, but only received d%.", | ||
ins.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.
这里为什么要删掉?
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.
因为 numpy.meshgrid
支持一个 tensor 输入和空输入,而 array-api-tests 包含了一个 tensor 输入的测试。
也可以修改成下面这样,不过 paddle/fluid/pybind/eager_utils.cc
会进行强制的输入非空检查,所以可能没有太多必要
PADDLE_ENFORCE_GT(
ins.size(),
0,
common::errors::InvalidArgument(
"Expected at least 1 input tensors, but only received %d.",
ins.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.
好的
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.
如果允许空输入的话,meshgrid()
这种case有测试吗?
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.
事实上 torch.meshgrid
同样不支持空输入,支持空输入的只是 numpy.meshgrid
,paddle.meshgrid
同样也不支持(creation 相关应该都不支持),我会把大于 0 的检查加上的。
test/legacy_test/test_meshgrid_op.py
Outdated
np.testing.assert_array_equal(res_1.shape, [100, 0]) | ||
np.testing.assert_array_equal(res_2.shape, [100, 0]) | ||
|
||
def test_api_with_static_empty_input(self): |
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]是否能够正常运算
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.
好的
…e positive check in `./paddle/phi/kernels/impl/meshgrid_kernel_impl.h`
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,可以再提一个PR改下这两个review,这个PR先合了
@@ -1,4 +1,4 @@ | |||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. | |||
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved. |
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.
2020->2024
for i, shape in enumerate(shapes) | ||
] | ||
exe = base.Executor(place=place) | ||
grid_results = paddle.tensor.meshgrid(data_tensors) |
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.
用paddle.meshgrid这个公开的API调用比较好
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
忽略 meshgrid API 在少于两个输入下的错误检查(该 API 本身即支持 0-size tensor 的输入),编写 0-size tensor 输入下的测试
