-
Notifications
You must be signed in to change notification settings - Fork 5.8k
【Hackathon 6th No.9】fix reshape op with zero-size tensor input in static mode -part #65639
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提交成功,感谢你对开源项目的贡献! |
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描述里 写一下被修改了的case情况吧
paddle/fluid/operators/reshape_op.cc
Outdated
in_dims.size())); | ||
output_shape[i] = shape[i]; | ||
} else if (shape[i] == 0) { | ||
if (static_cast<int>(i) < in_dims.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.
能否以 if (in_size == 0) 来写一个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.
那就改成像原来这样吗:#50389
原来这样应该是可以支持 [2, 3, 0, 4] -> [0, 4] 得到 [0, 4] 的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.
那就改成像原来这样吗:#50389 原来这样应该是可以支持 [2, 3, 0, 4] -> [0, 4] 得到 [0, 4] 的case
就是你想改的这个写法 也可以写成if (in_size==0) 和 else两个分支的形式
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是想修复静态图输出是 None 的问题,上一个 pr 是增加了支持的 case |
这个在描述里具体举例一下适配了哪种case及前后的变换吧,因为你在其他PR中遇到的问题,其他人review也不了解背景。 |
好的 |
python/paddle/tensor/manipulation.py
Outdated
"But received shape[%d] = 0, X's dimensions = %d." | ||
% (dim_idx, len(x.shape)) | ||
) | ||
import math |
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 放全局吧
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
本 pr 是修复 【Hackathon 6th No.9】Add cartesian_prod API to Paddle -part #65605 (comment) 出现的问题:静态图下
paddle.reshape 的输入如果是 zero-size tensor,结果返回的是 None。
修改前:
修改后:
本 pr 把之前对 infermeta/unary.cc 中 ValidateShape 的修改迁移到了 fluid/operator/reshape_op.cc 的 ValidateShape 中,
之前的修改是:【Hackathon 6th No.9】Update ValidateShape to support zero sized tensor flatten -part #64715 ,相比当时修改之前增加支持的 case 是:当输入是
zero-size tensor,且 output_shape 中 0 出现的位置小于 in_dims.size(),例如:
修改前:
修改后: