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

【Infer Symbolic Shape No.124】【BUAA】Add bmm, changed 3 files #67431

Closed
wants to merge 6 commits into from

Conversation

Whsjrczr
Copy link
Contributor

@Whsjrczr Whsjrczr commented Aug 14, 2024

PR Category

CINN

PR Types

Others

Description

加入bmm, broadcast_tensors:
paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/binary_infer_sym.cc
paddle/fluid/pir/dialect/operator/interface/infer_symbolic_shape/binary_infer_sym.h
paddle/phi/ops/yaml/ops.yaml
本地测试pir=True且通过
截屏2024-08-15 16 17 53

Copy link

paddle-bot bot commented Aug 14, 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.

@luotao1 luotao1 added contributor External developers HappyOpenSource Pro 进阶版快乐开源活动,更具挑战性的任务 labels Aug 14, 2024
Comment on lines 235 to 245
auto cal_shape_fn = [](const symbol::DimExpr &x,
const symbol::DimExpr &y,
const std::string &error_str) -> symbol::DimExpr {
if (x == -1) {
return y;
} else if (y == -1) {
return x;
}
PADDLE_ENFORCE_EQ(x, y, common::errors::InvalidArgument(error_str, x, y));
return x;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

DimExpr不可能为-1,这段逻辑是想给两个DimExpr加约束

"in BmmOp, but received Y's shape: [%d].",
y_ndims));

auto cal_shape_fn = [](const symbol::DimExpr &x,
Copy link
Contributor

Choose a reason for hiding this comment

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

删掉这个lambda表达式,调用cal_shape_fn的地方都使用 addequalcstr

return x;
};

cal_shape_fn(x_dims[2],
Copy link
Contributor

Choose a reason for hiding this comment

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

修改为 equal constrain

y_dims[1],
"Input(X)'s width must be equal with Input(Y)'s height in "
"BmmOp, but receive X's width: [%d], Y's height: [%d].");
symbol::DimExpr batch_size = cal_shape_fn(
Copy link
Contributor

@gongshaotian gongshaotian Aug 19, 2024

Choose a reason for hiding this comment

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

同上,batch_size 直接取其中一个Dim就行

const auto &y_shape_or_data =
infer_context->GetShapeOrDataForValue(op->operand_source(1));

const std::vector<symbol::DimExpr> &x_dims = x_shape_or_data.shape();
Copy link
Contributor

Choose a reason for hiding this comment

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

命名不规范,x_shape

infer_context->GetShapeOrDataForValue(op->operand_source(1));

const std::vector<symbol::DimExpr> &x_dims = x_shape_or_data.shape();
const std::vector<symbol::DimExpr> &y_dims = y_shape_or_data.shape();
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

Hongqing-work
Hongqing-work previously approved these changes Aug 23, 2024
@luotao1
Copy link
Contributor

luotao1 commented Aug 26, 2024

冲突了

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