-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[0-size Tensor Job2 No.51] Add 0-size Tensor support for paddle.multiplex [fluid_ops] #74212
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提交成功,感谢你对开源项目的贡献! |
|
/re-run all-failed |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (0.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #74212 +/- ##
==========================================
Coverage ? 0.00%
==========================================
Files ? 1
Lines ? 1
Branches ? 0
==========================================
Hits ? 0
Misses ? 1
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/re-run all-failed |
|
@DanielSun11 CI已完成需要review |
| ins.size(), | ||
| errors::PreconditionNotMet( | ||
| "index exceeds the number of candidate tensors.")); | ||
| if (ins[k]->numel() == 0) continue; |
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.
所有的tensor都不为0-size或者都为0-size,这里处理的是所有的tensor numel都为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.
也就是说修改后的paddle.multiplex只能支持输入全部为0 size或者输入全部为非0 size的情况吗?如果是这样的,infermeta和符号推导就没有必要改了。https://www.paddlepaddle.org.cn/documentation/docs/zh/3.0-beta/api/paddle/multiplex_cn.html#multiplex 规定了所有输入的shape必须相同,如果输入为0 size则其所有输入的shape也要求相同。只需要在kernel中判断如果out的numel为0,就直接return,就可以了吧?shape不同的为非法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.
也就是说修改后的paddle.multiplex只能支持输入全部为0 size或者输入全部为非0 size的情况吗?如果是这样的,infermeta和符号推导就没有必要改了。https://www.paddlepaddle.org.cn/documentation/docs/zh/3.0-beta/api/paddle/multiplex_cn.html#multiplex 规定了所有输入的shape必须相同,如果输入为0 size则其所有输入的shape也要求相同。只需要在kernel中判断如果out的numel为0,就直接return,就可以了吧?shape不同的为非法case
输入可以包含0-size和非0-size,输出取非0-size的shape,但是index选择的时候,选择的是非0-size项,如果都是选择0-size项,kernel结尾要Resize,这里看下torch的规则大概可以明白,构造temp时都是非0-size或者都是0-size,但是输入可以是不同的

文档描述shape是一致,但是0-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.
import paddle
x1 = paddle.randn([3, 3],dtype=paddle.float32)
x2 = paddle.randn([3, 0],dtype=paddle.float32)
print(x1)
print(x2)
index = paddle.to_tensor([[0],[1]],dtype=paddle.int32)
z = paddle.multiplex([x1, x2], index)
print(z)
请验证下这个代码的输出
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.
那还是按简单的处理,规则复杂也不容易维护,输入shape都一致 测试用例修改PR PFCCLab/PaddleAPITest#444
|
/re-run all-failed |
DanielSun11
left a comment
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
| ins.size(), | ||
| errors::PreconditionNotMet( | ||
| "index exceeds the number of candidate tensors.")); | ||
| if (ins[k]->numel() == 0) continue; |
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.
import paddle
x1 = paddle.randn([3, 3],dtype=paddle.float32)
x2 = paddle.randn([3, 0],dtype=paddle.float32)
print(x1)
print(x2)
index = paddle.to_tensor([[0],[1]],dtype=paddle.int32)
z = paddle.multiplex([x1, x2], index)
print(z)
请验证下这个代码的输出
PR Category
Operator Mechanism
PR Types
Bug fixes
Description
输入shape一致都为0-size,判断out numel返回
PaddleAPITest中为自定义规则torch.stack

https://github.com/PFCCLab/PaddleAPITest/blob/81e9f10d78ec53b8a56684b75bcdcf108f38a43f/tester/paddle_to_torch/rules.py#L3795
增加单测

PaddleAPITest测试通过,错误为 torch error