Skip to content
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

【BUAA】【Infer Symbolic Shape No.152,153】Add max_pool2d_with_index and max_pool3d_with_index #67390

Merged
merged 10 commits into from
Aug 16, 2024

Conversation

Fripping
Copy link
Contributor

PR Category

CINN

PR Types

Others

Description

添加 max_pool2d_with_index和 max_pool3d_with_index 算子符号推导接口实现。

Copy link

paddle-bot bot commented Aug 13, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Aug 13, 2024
@luotao1 luotao1 added the HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 label Aug 14, 2024
@Fripping
Copy link
Contributor Author

coverage_exit: 9

max_pool2d_with_index和 max_pool3d_with_index均无相应OpTest文件

Comment on lines 1325 to 887
const auto &x = x_shape[i + 2];
if (x.isa<int64_t>()) {
kernel_size_[i] = static_cast<int64_t>(x.Get<std::int64_t>());
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该不需要特判x是否为int64,kernel_size_直接变成DimExpr参与符号计算即可

Comment on lines 1348 to 1357
int64_t x = static_cast<int64_t>(x_dim.Get<std::int64_t>());
if (x < 0) {
out_shape.push_back(x_shape[i + 2]);
} else {
PADDLE_ENFORCE_NE(
strides[i],
0,
phi::errors::InvalidArgument(
"The stride of MaxPool shall not be 0, but received %d.",
strides[i]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

直接使用符号计算,这里x<0是infer meta无法处理动态shape做的特判

Comment on lines +1386 to +972
bool MaxPool3dWithIndexOpInferSymbolicShape(
pir::Operation *op, pir::InferSymbolicShapeContext *infer_context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

两个函数有很多相同逻辑,建议抽象点共同操作

Copy link
Contributor

@gongshaotian gongshaotian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luotao1 luotao1 merged commit 23dae0a into PaddlePaddle:develop Aug 16, 2024
28 checks passed
std::vector<int> strides =
paddle::dialect::details::GetVectorAttr<int>(op, "strides");
std::vector<int> kernel_sizes_ =
paddle::dialect::details::GetVectorAttr<int>(op, "kernel_sizes");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kernel_size

@gongshaotian
Copy link
Contributor

typo修复PR:#67548

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants