CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[PIR+CINN]add merge reshape with broadcast pass #60533
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
[PIR+CINN]add merge reshape with broadcast pass #60533
Conversation
Sorry to inform you that 05ba879's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
… add_merge_reshape_with_broadcast_pass
namespace ir { | ||
|
||
bool CanMerge(pir::Operation* op) { | ||
auto in_dims = op->operand_source(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.
auto in_dims = op->operand_source(0) | |
auto& in_dims = op->operand_source(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.
done
.type() | ||
.dyn_cast<paddle::dialect::DenseTensorType>() | ||
.dims(); | ||
auto out_dims = |
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.
auto out_dims = | |
auto &out_dims = |
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.
done
|
||
std::vector<int64_t> GetBroadcastAxis(pir::Operation* reshape_op, | ||
pir::Operation* broadcast_op) { | ||
auto in_dims = |
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.
auto in_dims = | |
auto &in_dims = |
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.
这个有phi::vectorize 操作,不能用 &
.type() | ||
.dyn_cast<paddle::dialect::DenseTensorType>() | ||
.dims()); | ||
auto out_dims = |
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.
auto out_dims = | |
auto& out_dims = |
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.
这个有phi::vectorize 操作,不能用 &
|
||
std::vector<int64_t> new_broadcast_axes(in_dims.size(), 0); | ||
// two step alignment | ||
// 1 step |
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.
done
op_broadcast_axes[forward_out_index]; | ||
} | ||
|
||
for (auto dim : new_broadcast_axes) { |
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.
done
pir::RewritePatternSet MergeReshapeWithBroadcastPass::InitializePatterns( | ||
pir::IrContext* context) { | ||
pir::RewritePatternSet ps(context); | ||
// elementwise ops |
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.
done
… add_merge_reshape_with_broadcast_pass
… add_merge_reshape_with_broadcast_pass
… add_merge_reshape_with_broadcast_pass
PR types
Function optimization
PR changes
Others
Description
Pcard-67164
由于cinn里面的broadcast 自带了reshape功能,因此把连续的reshape和broadcast 进行合并