-
Notifications
You must be signed in to change notification settings - Fork 1.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
[XShape] Xshape is alternative for flatten op #10088
Conversation
Thanks for your contribution! |
lite/operators/flatten_op.cc
Outdated
@@ -80,21 +80,26 @@ bool FlattenOp::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) { | |||
|
|||
bool Flatten2Op::CheckShape() const { | |||
FlattenOp::CheckShape(); | |||
CHECK(param_.xshape); | |||
if (has_xshape_) CHECK(param_.xshape); |
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.
是不是可以直接删除了
lite/operators/flatten_op.cc
Outdated
return true; | ||
} | ||
|
||
bool Flatten2Op::InferShapeImpl() const { | ||
FlattenOp::InferShapeImpl(); | ||
auto x_shape = param_.x->dims().Vectorize(); | ||
x_shape.insert(x_shape.begin(), 0); | ||
param_.xshape->Resize(x_shape); | ||
if (has_xshape_) param_.xshape->Resize(x_shape); |
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 (param_.xshape)
param_.xshape->Resize(x_shape);
return true; | ||
} | ||
|
||
bool Flatten2Op::AttachImpl(const cpp::OpDesc &opdesc, lite::Scope *scope) { | ||
FlattenOp::AttachImpl(opdesc, scope); | ||
param_.xshape = scope->FindMutableTensor(opdesc.Output("XShape").front()); | ||
if (opdesc.HasOutput("XShape")) { |
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-Lite/lite/operators/reshape_op.cc
Line 173 in b0a3c98
if (opdesc.HasInput("Shape") && !opdesc.Input("Shape").empty()) { |
这样是不是可以不用引入新的变量 has_xshape_ 了?
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 devices
Host
PR types
Bug fixes
PR changes
OP
Description
Xshape is alternative for flatten op;